         trashButton = false
         
         trashBut.enabled = false
+    }
+    
+    //filter user input
+    func updateSearchResultsForSearchController(searchController: UISearchController) {
+        filteredTableData.removeAll(keepCapacity: false)
+        tempArray_url.removeAll(keepCapacity: false)
+        tempIndexes.removeAll(keepCapacity: false)
         
         let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
         let array = (tempArray_title as NSArray).filteredArrayUsingPredicate(searchPredicate)

    func searchBarTextDidEndEditing(searchBar: UISearchBar) {
        if(searchBar.text == "") { //redisplay table data if search bar is nil
            resultSearchController.active = false
            trashBut.enabled = true
            windowView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
            navBar.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
            UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseIn, animations: {
                self.navBar.frame.origin.x = -55
                }, completion: { finished in
            })
            if(mainView == 0) {
                if(tempArray_title.count == 0) { //switch off history while history is empty
                    historyBackToNormal()
                    view.makeToast("History is empty...", duration: 0.8, position: CGPoint(x: view.frame.size.width-120, y: UIScreen.mainScreen().bounds.height-70)) //alert user
                }
            } else if(mainView == 2) {
                if(tempArray_title.count == 0) { //switch off likes while bookmark is empty
                    bookmarkBackToNormal()
                    view.makeToast("You didn't like any...", duration: 0.8, position: CGPoint(x: view.frame.size.width-120, y: UIScreen.mainScreen().bounds.height-70)) //alert user instead of switching to bookmarks
                }
            }
        }
    }
    

        resultSearchController.searchBar.endEditing(true)
    }
    
    func didDismissSearchController(searchController: UISearchController) {
        windowView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
        navBar.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
        UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseIn, animations: {
            self.navBar.frame.origin.x = -55
            }, completion: { finished in
        })
        trashButton = false
        trashBut.enabled = true
    }
    
    func didPresentSearchController(searchController: UISearchController) {
        searchController.searchBar.showsCancelButton = false
        searchController.searchBar.frame = searchFrame
        
        windowView.transform = CGAffineTransformMakeRotation(0)
        navBar.transform = CGAffineTransformMakeRotation(0)
