     // http://stackoverflow.com/questions/26845307/generate-random-alphanumeric-string-in-swift
     func randomStringWithLength(_ len: Int) -> String {
         let letters = Array("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".characters)
-
+        
         var randomString = String()
         for _ in 0..<len {
             let length = UInt32(letters.count)
             let rand = arc4random_uniform(length)
-			randomString += String(letters[Int(rand)])
+            randomString += String(letters[Int(rand)])
         }
         return String(randomString)
     }
 }
+
+// This extension is used for random numbers
+public extension ExpressibleByIntegerLiteral {
+    public static func arc4random() -> Self {
+        var r: Self = 0
+        arc4random_buf(&r, MemoryLayout<Self>.size)
+        return r
+    }
+}
+

    }
    
    func appendStringToTextView(_ string: String) {
        textView.text = "\(textView.text ?? "")\n\(string)"
        let range = NSMakeRange(textView.text.characters.count - 1, 1)
        textView.scrollRangeToVisible(range)
    }
    
    // MARK: - MQTTSessionDelegates

    func mqttDidReceive(message: MQTTMessage, from session: MQTTSession) {
        appendStringToTextView("data received on topic \(message.topic) message \(message.stringRep ?? "<>")")
    }
    
    func mqttDidDisconnect(session: MQTTSession, reson: MQTTSessionDisconnect, error: Error?) {

    }
    
    func subscribeToChannel() {
        let subChannel = "Message/59967c86a07ffa3ccdb1cf47"
        mqttSession.subscribe(to: subChannel, delivering: .atMostOnce) {
            if !$1 {
                self.appendStringToTextView("Error Occurred During subscription \($2)")
                return
            }
            self.appendStringToTextView("Subscribed to \(subChannel)")
