fixed bug in usage of timer