fixed end-of-the-game condition not triggering properly