                 controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
                 controller.navigationItem.leftItemsSupplementBackButton = true
 
-                if let row = rows?.rowAtIndex(UInt(indexPath.row)),
+                if let row = liveQuery?.rows?.rowAtIndex(UInt(indexPath.row)),
                     let name = row.key as? String {
                         controller.detailItem = name
                 }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

        if let row = rows?.rowAtIndex(UInt(indexPath.row)),
            let name = row.key as? String {
                cell.textLabel?.text = name
        }


    var detailViewController: ChatViewController? = nil

    private var liveQuery: CBLLiveQuery?

    var database: CBLDatabase = {
        let app = UIApplication.sharedApplication().delegate as! AppDelegate
