     }
     
     func outsidePendingSegment() {
+        self.checkingForPendingConnections = false
         friendsTableView.tableHeaderView = nil
         self.resultSearchController.active = false
     }

            
            case 1:
                currentSegmentedControl = "contacts"
//                self.checkingForPendingConnections = false
//                self.checkingForContacts = true
                clearUsersArrayAndReloadTableView()
                outsidePendingSegment()
                contactsSegmentWasPicked()
            
            case 2:
                currentSegmentedControl = "facebook"
//                self.checkingForPendingConnections = false
//                self.checkingForContacts = false
                clearUsersArrayAndReloadTableView()
                outsidePendingSegment()
                facebookSegmentWasPicked()
            
            case 3:
                currentSegmentedControl = "twitter"
//                self.checkingForPendingConnections = false
//                self.checkingForContacts = false
                clearUsersArrayAndReloadTableView()
                outsidePendingSegment()
                twitterSegmentWasPicked()

                        }
                    }
                }
                
                // Sort Contacts by GivenName
                self.contacts.sortInPlace({ (contact1, contact2) -> Bool in
                    return contact1["givenName"] < contact2["givenName"]
                })
            }
        }
        catch{
