update game logic and clean up code