         }
         
         let resultBytes: [UInt8] = [channel, command, hiByte, loByte] + pixelBytes
-        let resultData = NSData(bytes: resultBytes, length: resultBytes.count * sizeof(UInt8))
+        sendByteArray(bytes: resultBytes)
+    }
+    
+    private func sendByteArray(bytes: [UInt8]) {
+        let bytesData = NSData(bytes: bytes, length: bytes.count * sizeof(UInt8))
         do {
-            try socket?.write(from: resultData)
+            try socket?.write(from: bytesData)
         } catch {
-            "Print cannot send data"
+            print("cannot send data")
         }
     }
 }

        }
    }
    
    func checkIfConnected() -> Bool {
        if socket == nil {
            connect()
            return false

        socket?.close()
    }
    
    private func sendConfigPackage() {
        let configBytesArray: [UInt8] = [0, 0xFF, 0, 5, 0x00, 0x01, 0x00, 0x02, configByte]
        sendByteArray(bytes: configBytesArray)
    }
    
    public func setPixels(pixels: [PixelColor], channel: UInt8 = 0) {
        guard checkIfConnected() == true else {
            print("Not connected, skipping this command")
