     }.first! as! FriendCellInfo
     cell.configure(cellInfo: cellInfo)
     cell.accessoryType =
-        dataSource.selectedFriends.contains(cellInfo.fbid) ? .checkmark : .none
+        dataSource.selectedContacts.contains(cellInfo.fbid) ? .checkmark : .none
     return cell
   }
 
   func sectionIndexTitles(for tableView: UITableView) -> [String]? {
-    return dataSource.sortedFriends.keys.sorted()
+    return dataSource.sortedContacts.keys.sorted()
   }
 }
 
 extension ContactPicker : UITableViewDelegate {
   func numberOfSections(in tableView: UITableView) -> Int {
-    return dataSource.sortedFriends.keys.count
+    return dataSource.sortedContacts.keys.count
   }
 
   func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int)
       -> String? {
-    return dataSource.sortedFriends.keys.sorted()[section]
+    return dataSource.sortedContacts.keys.sorted()[section]
   }
 
   func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int)
       -> Int {
-    let key = dataSource.sortedFriends.keys.sorted()[section]
-    return (dataSource.sortedFriends[key]?.count)!
+    let key = dataSource.sortedContacts.keys.sorted()[section]
+    return (dataSource.sortedContacts[key]?.count)!
   }
 
   func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell,
                  forRowAt indexPath: IndexPath) {
-    let contact = self.contact(for: indexPath)
-    let cellInfo = dataSource.cells.filter { (ci) in
-      return (ci as! FriendCellInfo).fbid == contact
-    }.first! as! FriendCellInfo
-    cell.accessoryType =
-        dataSource.selectedFriends.contains(cellInfo.fbid) ? .checkmark : .none
+    guard let contact = self.contact(for: indexPath) else {
+      cell.accessoryType = .none
+      return
+    }
+    cell.accessoryType = isSelected(fbid: contact) ? .checkmark : .none
   }
 
   func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath)

extension ContactPicker {
  fileprivate func contact(for indexPath: IndexPath) -> String? {
    guard
      let key = dataSource.sortedFriends.keys.sorted()[safe: indexPath.section],
      let contacts = dataSource.sortedFriends[key]
    else {
        return nil
    }
    return contacts[safe: indexPath.row]!
  }
}



  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if let cell = tableView.cellForRow(at: indexPath) {
      guard let contact = self.contact(for: indexPath) else { return }
      selectContact(fbid: contact)
      cell.accessoryType = .checkmark
    }
  }
