fixing endgame bug