Fix bug with checking endgame at the right spot