             throw GzipError(code: status, msg: stream.msg)
         }
         
-        var data = Data(capacity: contiguousData.count * 2)
-        
+        var data = Data(capacity: self.count * 2)
         repeat {
             if Int(stream.total_out) >= data.count {
-                data.count += contiguousData.count / 2
+                data.count += self.count / 2
             }
             
             data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<Bytef>) in

        guard !self.isEmpty else {
            return Data()
        }

        let contiguousData = self.withUnsafeBytes { Data(bytes: $0, count: self.count) }
        var stream = contiguousData.createZStream()
        var status: Int32

            }
            stream.avail_out = uInt(data.count) - uInt(stream.total_out)
            
            status = deflate(&stream, Z_FINISH)
        }
        
        guard deflateEnd(&stream) == Z_OK, status == Z_STREAM_END else {
            throw GzipError(code: status, msg: stream.msg)
        }
        
        data.count = Int(stream.total_out)
        
        return data
