Could write it in terms of Piecewise.
Piecewise
Have you considered using a WhenEvent? I had a similar problem once myself. Check out the docs as well. It would be nice if you posted the code so one can copy it at run it easily instead of screenshoting it.
WhenEvent
thanks man, but I still can't get it using "While" though the site on doc recommended was helpful. Anyway I've attached the nb. file and hopefully and you can test it out. I appreciate your help very much.
Best regards, Aaron Aw