fix end-of-game bug