Added endgame check