     
     func handlePlayerCollisionEvent(player: Player, xCoordinate: Int?) {
         player.run()
+        let validToSend = isValidToSend(player)
+        
         if player.playerNumber == state.myPlayer.playerNumber {
             player.fallBehind()
             state.addCollideEvent(timeStep, xCoordinate: player.xCoordinate)
             player.becomeInvulnerable(timeStep)
-            if isValidToSend(player) {
+            if validToSend {
                 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) {
+                if validToSend {
                     sendPlayerLostData(score)
                 }
                 
+                player.lost()
+
                 checkRaceFinished()
             }
         } else {

    
    func gameEndSignalReceived(data: AnyObject?, peer: MCPeerID) {
        // Stop the update() method
        state.gameIsOver = true
    }
    

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