added some end game logic