fixed end game condition logic