refactored and added more game logic