fixed the endgame bug