     
     private func checkRaceFinished() {
         if state.everyoneFinished() {
+            print("everyone finished")
             // Stop the update() method
             state.gameIsOver = true
             

    
    func handlePlayerCollisionEvent(player: Player, xCoordinate: Int?) {
        player.run()
        if player.playerNumber == state.myPlayer.playerNumber {
            player.fallBehind()
            state.addCollideEvent(timeStep, xCoordinate: player.xCoordinate)
            player.becomeInvulnerable(timeStep)
            if isValidToSend(player) {
                sendCollisionData(player.xCoordinate)
            }
            // If player fell off the grid, he finished the race
            if player.xCoordinate < 0 {
                state.updatePlayerScore(myPeerID, score: score)
                player.lost()
                
                if isValidToSend(player) {
                    sendPlayerLostData(score)
                }
                
                checkRaceFinished()
            }
        } else {

    
    func update() {
        guard !state.gameIsOver else {
            print("game is over")
            return
        }
        updateEventQueue()
