             var offset = 2
             if((isMasked > 0 || (RSVMask & buffer[0]) > 0) && receivedOpcode != OpCode.Pong.rawValue) {
                 let errCode = CloseCode.ProtocolError.rawValue
+                let error = self.errorWithDetail("masked and rsv data is not currently supported", code: errCode)
                 if let failBlock = self._failureBlock{
-                    failBlock(self.errorWithDetail("masked and rsv data is not currently supported",
-                        code: errCode))
+                    failBlock(error)
                 }
                 else{
-                    self.delegate?.websocketDidDisconnect!(self.errorWithDetail("masked and rsv data is not currently supported",
-                    code: errCode))
+                    self.delegate!.websocketDidDisconnect(error)
                 }
                 writeError(errCode)
                     

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

            }
            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(error)
                }
                else{
                    self.delegate!.websocketDidDisconnect(error)
                }
                writeError(errCode)
                return
