So instead of adding if check statement moving the code inside it, I added ( runningTime = 0.0; ) in the else statement of Scarfy is in the air. That also worked.
Can you please tell me any drawbacks by doing this or this is also a right way?
Added a screenshot.