Made some refactoring in the timer