             return callback(.Error(SuvError.RuntimeError(message: "Stream is already closed")))
         }
         
-        onRead2 = { result in
+        let onRead2: GenericResult<Pipe> -> () = { result in
             if case .Success(let queue) = result {
                 let pipePtr = UnsafeMutablePointer<uv_pipe_t>(queue.streamPtr)
                 if uv_pipe_pending_count(pipePtr) <= 0 {

                result = .Success(pipe)
            }
            
            stream.onRead2(result)
        }
        
        if r < 0 {

        }
        
        var data = uv_buf_init(bytes, length)
        
        withUnsafePointer(&data) {
            let writeReq = UnsafeMutablePointer<uv_write_t>(allocatingCapacity: sizeof(uv_write_t))
            writeReq.pointee.data = retainedVoidPointer(onWrite)
            
            let r = uv_write(writeReq, streamPtr, $0, 1) { req, _ in
                let onWrite: Result -> () = releaseVoidPointer(req.pointee.data)!
                destroy_write_req(req)
                onWrite(.Success)
            }
            
            if r < 0 {
