fix end of game detection