         
         self.pushReplicator.delegate = self
         self.doingPullReplication = false
-        self.refreshControl?.attributedTitle = NSAttributedString(string: "Pushing Items to Cloudant")
-        
+        
+        //update UI in main thread
+        dispatch_async(dispatch_get_main_queue()) {
+            self.refreshControl?.attributedTitle = NSAttributedString(string: "Pushing Items to Cloudant")
+        }
+            
         error = nil
         do {
             try self.pushReplicator.start()

        let selectedPriority = item.body()[PRIORITY_FIELD]!.integerValue
        let newPriority = self.getNextPriority(selectedPriority)
        item.body()[PRIORITY_FIELD] = NSNumber(integer: newPriority)
        cell.imageView?.image = self.getPriorityImage(newPriority)
        self.updateItem(item)
    }
    
    func getNextPriority(currentPriority: Int) -> Int {

            return item1.body()[NAME_FIELD]!.localizedCaseInsensitiveCompare(item2.body()[NAME_FIELD]! as! String) == .OrderedAscending
        }
        if self.tableView != nil {
            dispatch_async(dispatch_get_main_queue()) {
                self.tableView.reloadData()
            }
        }
    }
    
