 // MARK: UISearchResultsUpdating
 extension ViewController: UISearchResultsUpdating {
   func filterContentForSearch (searchText: String, scope: Int) {
-    self.filteredSuggestedSearchFoods = self.suggestedSearchFoods.filter({ (food: String) -> Bool in
-      var foodMatch = food.rangeOfString(searchText)
-      return foodMatch != nil
-    })
+    if scope == 0 {
+      self.filteredSuggestedSearchFoods = self.suggestedSearchFoods.filter({ (food: String) -> Bool in
+        var foodMatch = food.lowercaseString.rangeOfString(searchText.lowercaseString)
+        return foodMatch != nil
+      })
+    } else if scope == 2 {
+      self.filteredFavoritedUSDAItems = self.favoritedUSDAItems.filter({ (item: USDAItem) -> Bool in
+        var stringMatch = item.name.lowercaseString.rangeOfString(searchText.lowercaseString)
+        return stringMatch != nil
+      })
+    }
   }
   
   func updateSearchResultsForSearchController(searchController: UISearchController) {

  @IBOutlet weak var tableView: UITableView!
  
  var searchController: UISearchController!
  var suggestedSearchFoods: [String] = []
  var filteredSuggestedSearchFoods: [String] = []
   var apiSearchForFoods:[(name: String, idValue: String)] = []
  var searchString: String?
  var scopeButtonTitles = ["Recommended", "Search Results", "Saved"]
  var jsonResponse:NSDictionary!
  var dataController = DataController()
  var favoritedUSDAItems:[USDAItem] = []
 
  override func viewDidLoad() {
    super.viewDidLoad()

    } else if selectedScopeButtonIndex == 1 {
      return self.apiSearchForFoods.count
    } else {
      if self.searchController.active && self.searchString! != "" {
        return self.filteredFavoritedUSDAItems.count
      } else {
        return self.favoritedUSDAItems.count
      }
    }
  }
  
