         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
-    }
-    
-    //filter user input
-    func updateSearchResultsForSearchController(searchController: UISearchController) {
-        filteredTableData.removeAll(keepCapacity: false)
-        tempArray_url.removeAll(keepCapacity: false)
-        tempIndexes.removeAll(keepCapacity: false)
         
         windowView.transform = CGAffineTransformMakeRotation(0)
         navBar.transform = CGAffineTransformMakeRotation(0)

        trashButton = false
        
        trashBut.enabled = false
        
        let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
        let array = (tempArray_title as NSArray).filteredArrayUsingPredicate(searchPredicate)

            }
        }
        else if(mainView == 0) { //"history" mode
            if(resultSearchController.active) { //while search controller opens in history mode
                tempIndexes = tempIndexes.unique
                filteredTableData.removeAtIndex(cell_row)
                tempArray_url.removeAtIndex(cell_row)
                tempArray_title.removeAtIndex(tempIndexes[cell_row])
                slideViewValue.historyUrl.removeAtIndex(tempIndexes[cell_row])
                slideViewValue.historyDate.removeAtIndex(tempIndexes[cell_row])
                tempIndexes.removeAtIndex(cell_row)
                slideViewValue.historyTitle = tempArray_title
            } else {
                tempArray_title.removeAtIndex(cell_row)
                slideViewValue.historyUrl.removeAtIndex(cell_row)
                slideViewValue.historyDate.removeAtIndex(cell_row)
                slideViewValue.historyTitle = tempArray_title
                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) { //"likes" mode
