Fixed a bug in game over detection