         ]
 
         var messageBytes = headerBytes + encodeUTF8Length(client) + [UInt8](client.utf8)
-        if let username = self.username {
+
+        if let username = username {
             messageBytes += (encodeUTF8Length(username) + [UInt8](username.utf8))
         }
-        if let password = self.password {
+
+        if let password = password {
             messageBytes += (encodeUTF8Length(password) + [UInt8](password.utf8))
         }
+
         outputStream?.write(messageBytes, maxLength: messageBytes.count)
     }
 


        let publishBytes: [UInt8] = [
            0x30] +                             // FIXED BYTE 1   3 = PUBLISH, 0 = DUP QoS RETAIN

        remainingLengthBytes +                  // remaining length, variable

        [UInt16(topic.utf8.count).highByte,     // topic length MSB
            UInt16(topic.utf8.count).lowByte    // topic length LSB
        ]
        
        let messageBytes = publishBytes + [UInt8](topic.utf8) + [UInt8](message)
        outputStream?.write(messageBytes, maxLength: messageBytes.count)
    }
    
    @objc private func mqttPing(outputStream: OutputStream) {
        let messageBytes: [UInt8] = [
            0xc0,                               // FIXED BYTE 1   c = PINGREQ, 0 = DUP QoS RETAIN (not used)

        
        outputStream.write(messageBytes, maxLength: messageBytes.count)
    }
    
    // MARK: - Utils
    
    private func encodeVariableLength(_ length: UInt) -> [UInt8] {
        var remainingBytes: [UInt8] = []
        var workingLength = length
        
        while workingLength > 0 {
            var byte = UInt8(workingLength & 0x7F)
            workingLength >>= 7
