fix bug in endgame