move reseting time to main loop.