Implemented end of game detection