changed end game logic