cleaned up game logic and prevented the timer function from running several times at once