     }
     
     @IBAction func genreFilteringModeDidChange(sender: AnyObject) {
-        // Convert conjunctive refinements into disjunctive and vice versa.
-        let queryHelper = QueryHelper(query: movieSearcher.query)
-        let refinements = queryHelper.getFacetRefinements() { $0.name == "genre" }
-        for refinement in refinements {
-            queryHelper.removeFacetRefinement(refinement)
-        }
-        let disjunctive = genreFilteringModeSwitch.on
-        for refinement in refinements {
-            if disjunctive {
-                queryHelper.addDisjunctiveFacetRefinement(refinement)
-            } else {
-                queryHelper.addConjunctiveFacetRefinement(refinement)
-            }
-        }
+        movieSearcher.setFacet("genre", disjunctive: genreFilteringModeSwitch.on)
         search()
     }
     

            return
        }
        // Sort facets: first selected facets, then by decreasing count, then by name.
        let receivedQueryHelper = QueryHelper(query: results.lastQuery)
        genreFacets = results.facets("genre")?.sort({ (lhs, rhs) in
            // When using cunjunctive faceting ("AND"), all refined facet values are displayed first.
            // But when using disjunctive faceting ("OR"), refined facet values are left where they are.
            let disjunctiveFaceting = results.disjunctiveFacets.contains("genre") ?? false
            let lhsChecked = receivedQueryHelper.hasFacetRefinement(FacetRefinement(name: "genre", value: lhs.value))
            let rhsChecked = receivedQueryHelper.hasFacetRefinement(FacetRefinement(name: "genre", value: rhs.value))
            if !disjunctiveFaceting && lhsChecked != rhsChecked {
                return lhsChecked
            } else if lhs.count != rhs.count {

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        switch tableView {
            case genreTableView:
                movieSearcher.toggleFacetRefinement("genre", value: genreFacets[indexPath.item].value)
                movieSearcher.search()
                break
            default: return
