improved the implementation of the game logic