finish the logic of the game