fix end of game detection bug