             stream.close()
         }
         outputStream = nil
-        certValidated = false
-        doDisconnect(error)
+        inputStream = nil
     }
     
     ///handles the incoming bytes and sending them to the proper processing method

    //disconnect the stream object
    private func disconnectStream(error: NSError?) {
        writeQueue.waitUntilAllOperationsAreFinished()
        if let stream = inputStream {
            CFReadStreamSetDispatchQueue(stream, nil)
            stream.close()

        mutex.lock()
        readyToWrite = false
        mutex.unlock()
        cleanupStream()
    }
    
}
