     }
     
     override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
-        API.currentGroup = visibleGroups[indexPath.item]
+        API.currentGroup = visibleGroups()[indexPath.item]
         let vc = GroupViewController()
 
         vc.delegate = self



    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

        guard let idx = findGroupIndexById(groups, archivedGroup: visibleGroups[indexPath.item]) else {
            return
        }

        let archived = visibleGroups[indexPath.item].archived

        groups[idx].archived = !archived
        visibleGroups[indexPath.item].archived = !archived
        API.putGroup(visibleGroups[indexPath.item])
        .onSuccess {
            group in
            self.visibleGroups = self.groups.filter({ $0.archived == false })
            self.tableView.reloadData()
        }
        .onFailure {
            err in
            self.groups[idx].archived = archived
            self.visibleGroups[indexPath.item].archived = archived
        }
    }


        super.viewDidAppear(animated)
        API.getGroupsForUser().onSuccess { groups in
            self.groups = groups
            self.tableView.reloadData()
        }
    }

    func visibleGroups() -> [Group]{
        return self.groups.filter{group in return !group.archived || self.showArchived}
    }

    override func tableView(tableView: UITableView, shouldHighlightRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
