added check for endgame