     private func insertPlayer(player: Player) {
         state.players.append(player)
     }
+    
+    private func appendToEventQueue(event: GameEvent, playerNumber: Int, occurringTimeStep: Int) {
+        eventQueue.append((event: event, playerNumber: playerNumber, timeStep: occurringTimeStep))
+        eventQueue.sortInPlace { $0.timeStep > $1.timeStep }
+    }
 }
 
 // MARK: GameNetworkPortalGameStateDelegate
 extension LogicEngine: GameNetworkPortalGameStateDelegate {
-    func jumpActionReceived(data: [String : AnyObject], peer: MCPeerID) {
-
-    }
-
-    func duckActionReceived(data: [String : AnyObject], peer: MCPeerID) {
-
-    }
-
-    func collideActionReceived(data: [String : AnyObject], peer: MCPeerID) {
-
-    }
-
-    func gameStartSignalReceived(data: [String : AnyObject], peer: MCPeerID) {
+    func jumpActionReceived(data: AnyObject, peer: MCPeerID) {
+        guard let playerNumber = state.peerMapping[peer],
+            dataDict = data as? [String: AnyObject] else {
+            return
+        }
+        guard let timeStepOccurrenceString = dataDict["time_step"] as? String else {
+            return
+        }
+        guard let occurringTimeStep = Int(timeStepOccurrenceString) {
+            return
+        }
+        appendToEventQueue(.PlayerDidJump, playerNumber: playerNumber,
+                           occurringTimeStep: occurringTimeStep)
+    }
+
+    func duckActionReceived(data: AnyObject, peer: MCPeerID) {
+        guard let playerNumber = state.peerMapping[peer],
+            dataDict = data as? [String: AnyObject] else {
+                return
+        }
+        guard let timeStepOccurrenceString = dataDict["time_step"] as? String else {
+            return
+        }
+        guard let occurringTimeStep = Int(timeStepOccurrenceString) {
+            return
+        }
+        appendToEventQueue(.PlayerDidDuck, playerNumber: playerNumber,
+                           occurringTimeStep: occurringTimeStep)
+    }
+
+    func collideActionReceived(data: AnyObject, peer: MCPeerID) {
+
+    }
+
+    func gameStartSignalReceived(data: AnyObject, peer: MCPeerID) {
         if let player = gameState.getPlayer(withPeerID: peer) {
             player.ready()
         }
     }
 
-    func gameEndSignalReceived(data: [String : AnyObject], peer: MCPeerID) {
+    func gameEndSignalReceived(data: AnyObject, peer: MCPeerID) {
 
     }
 }
        timeStep += 1
    }

    func handleEvent(event: GameEvent, player: Int?) {
        if let player = state.players.filter({ $0.playerNumber == player }).first {
            switch event {
                case .PlayerDidJump:
                    player.jump(timeStep)
                case .PlayerDidDuck:
                    player.duck(timeStep)
                default:
                    break
            }
        }
    }
    

        guard !state.gameIsOver else {
            return
        }
        updateEventQueue()
        updateObstaclePositions()
        handleCollisions()
        updatePlayerStates()
