Recoding the game logic