fix stopping of loop when timer returns falsy value