refactoring of timer