Refactored gameOver function