Implement the logic for the timer.