         let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
 
         dispatch_after(time, handleQueue) {[weak self] in
-            if let this = self where this.status != .Connected && this.status != .Disconnected {
-                this.status = .Disconnected
-                this.engine?.disconnect("Connect timeout")
-
-                handler?()
-            }
+            guard let this = self where this.status != .Connected && this.status != .Disconnected else { return }
+            
+            this.status = .Disconnected
+            this.engine?.disconnect("Connect timeout")
+            
+            handler?()
         }
     }
 


    /// Disconnects the socket.
    public func disconnect() {
        assert(status != .NotConnected, "Tried closing a NotConnected client")
        
        DefaultSocketLogger.Logger.log("Closing socket", type: logType)

        didDisconnect("Disconnect")

        currentAck += 1

        return {[weak self, ack = currentAck] timeout, callback in
            guard let this = self else { return }
            
            dispatch_sync(this.ackQueue) {
                this.ackHandlers.addAck(ack, callback: callback)
            }
            
            
            this._emit(items, ack: ack)
            
            if timeout != 0 {
                let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
                
                dispatch_after(time, this.ackQueue) {
                    this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue)
                }
            }
        }
