         super.viewWillAppear(animated)
     }
 
+    deinit {
+        liveQuery?.removeObserver(self, forKeyPath: "rows")
+    }
+
     func insertNewObject(sender: AnyObject) {
-//        objects.insert(NSDate(), atIndex: 0)
-//        let indexPath = NSIndexPath(forRow: 0, inSection: 0)
-//        self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
-
         let newChatroom = database.createDocument()
         let properties = ["type": "chatroom", "name": "from code"]
 


    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
//            objects.removeAtIndex(indexPath.row)
//            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
        }

        let live = query.asLiveQuery()
        live.descending = true

        live.addObserver(self, forKeyPath: "rows", options: [], context: nil)

        liveQuery = live
    }

    override func viewWillAppear(animated: Bool) {
