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

            //doing push, push is done read items from local data store and end the refresh UI
            self.listItems({ () -> Void in
                self.logger.logDebugWithMessages("Done refreshing table after replication")
                self.refreshControl?.attributedTitle = NSAttributedString(string: " ")
                self.refreshControl?.endRefreshing()
                self.settingsButton.enabled = true
            })
        }
    

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