     hx.defined validFilters
 
 
-getFiltered = (rows, term, filtered, filterCacheTerm, fn) ->
-  if (term?.length and (filtered is undefined or filterCacheTerm isnt term))
+getFiltered = (rows, term, filterCache, filterCacheTerm, fn) ->
+  # term can be a string (regular filter) or an array (advanced search)
+  if (term?.length and (filterCache is undefined or filterCacheTerm isnt term))
     rows.filter fn
-  else if filtered is undefined or not term?.length
+  else if filterCache is undefined or not term?.length
     rows.slice()
   else
-    filtered
+    filterCache
 
 objectFeed = (data, options) ->
   options = hx.merge({

    totalCount: (cb) -> cb(data.rows.length)
    rows: (range, cb) ->
      if range.sort?.column isnt sortCacheTerm.column
        filtered = undefined

      if range.useAdvancedSearch
        advancedSearchFilterFn = (row) -> options.advancedSearch(range.advancedSearch, row)
        filtered = getFiltered(data.rows, range.advancedSearch, filtered, filterCacheTerm, advancedSearchFilterFn)
        filterCacheTerm = range.advancedSearch
        sorted = undefined
      else
        filterFn = (row) -> options.filter(range.filter, row)
        filtered = getFiltered(data.rows, range.filter, filtered, filterCacheTerm, filterFn)
        filterCacheTerm = range.filter
        sorted = undefined


        sorted = if range.sort and range.sort.column
          direction = if range.sort.direction is 'asc' then 1 else -1
          column = range.sort.column
          filterCache.sort (r1, r2) -> direction * options.compare(r1.cells[column], r2.cells[column])
          filterCache
        else filterCache
        sortCacheTerm.column = range.sort?.column
        sortCacheTerm.direction = range.sort?.direction

