                     if array.count == 0 {
                         return
                     }
-                    if value as! String == array[indexPath.row].uid {
+                    // something wrong?
+                    if array.count > indexPath.row && value as? String == array[indexPath.row].uid {
                         self.tableview.cellForRow(at: indexPath)?.accessoryType = .checkmark
                     }
                 }

    }
    
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let uid = FIRAuth.auth()!.currentUser!.uid

        retrieveUsers()
        
        open.target = self.revealViewController()
        searchBar.delegate = self
        searchDisplayController?.searchResultsDelegate = self;
        
        open.action = Selector("revealToggle:")
        
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
        
        //filteredUser = userMessages
        
    }
