     // MARK: Properties
     var messages = [JSQMessage]() // messages is an array to store the various instances of JSQMessage
     
-    
     var outgoingBubbleImageView: JSQMessagesBubbleImage!
     var incomingBubbleImageView: JSQMessagesBubbleImage!
     
-    // Firebase
+    // MARK: Firebase refs
     // In case you’re wondering, creating another reference doesn’t mean you’re creating another connection. Every reference shares the same connection to the same Firebase database.
     let rootRef = Firebase(url: BASE_URL)
     var messageRef = Firebase()
+    var userIsTypingRef: Firebase! // reference that tracks whether the local user is typing
+    var usersTypingQuery: FQuery!  // FQuery, which is just like a Firebase reference, except that it’s ordered by an order function.
+    
+    // Typing tracking related properties
+    private var localTyping = false // Store whether the local user is typing in a private property
+    var isTyping: Bool {
+        get {
+            return localTyping
+        }
+        set {
+            // Using a computed property, update userIsTypingRef each time user updates this property.
+            localTyping = newValue
+            userIsTypingRef.setValue(newValue)
+        }
+    }
+    
+    
+    
+    
+    
+    
     
     override func viewDidLoad() {
         super.viewDidLoad()

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        self.observeMessages()
    }
    
    

        // Start by creating a query that limits the synchronization to the last 25 messages.
        let messagesQuery = messageRef.queryLimitedToLast(25)
        
        // Use the .ChildAdded event to observe for every child item that has been added, and will be added, at the messages location.
        messagesQuery.observeEventType(FEventType.ChildAdded) { (snapshot:FDataSnapshot!) -> Void in
            
            // Extract the senderId and text from snapshot.value.
            
            if let id = snapshot.value["senderId"] as? String, text = snapshot.value["text"] as? String {
                
