             }
             if isFin == 0 && receivedOpcode == OpCode.ContinueFrame.rawValue && response == nil {
                 let errCode = CloseCode.ProtocolError.rawValue
+                let error = self.errorWithDetail("continue frame before a binary or text frame", code: errCode)
                 if let failBlock = self._failureBlock{
-                    failBlock(self.errorWithDetail("continue frame before a binary or text frame",
-                        code: errCode))
+                    failBlock(error)
                 }
                 else{
-                self.delegate?.websocketDidDisconnect!(self.errorWithDetail("continue frame before a binary or text frame",
-                    code: errCode))
+                    self.delegate!.websocketDidDisconnect(error)
                 }
                 writeError(errCode)
                 return

        if totalSize > 0 {
            if validateResponse(buffer, bufferLen: totalSize) {
                dispatch_async(dispatch_get_main_queue(),{
                    self.workaroundMethod()
                    if let connectBlock = self._connectedBlock{
                        connectBlock()
                    }
                    else{
                        self.delegate?.websocketDidConnect!()
                    }
                })
                totalSize += 1 //skip the last \n

                        failBlock(error)
                    }
                    else{
                       self.delegate!.websocketDidDisconnect(error)
                    }
                    
                    writeError(errCode)
