Fixing the timer function to pause properly.