Added end game state detection