module.exports = function (params, callbacks) {
  var parse;
  if ( typeof Parse == 'undefined' ) {
    // can't require parse from within parse cloud.  seems silly.
    parse = require('parse');
  } else {
    parse = Parse;
  }

  var _        = require('underscore');

  var Facility           = require('cloud/models/facility');

  // all params are optional, NULL or missing means don't filter
  // {
  //  sort: 'near'|'name'
  //  limit: int (default 10)
  //  filter:
  //    {isOpen: true,
  //     gender: 'M'|'F'
  //     age: ['C', 'Y', 'A', 'S'] // children, youth, adult, senior
  //     categories: ['medical', 'hygiene', 'food', 'shelter']
  //    }
  //  }
  //
  //

  var sort = params.sort || 'name';
  var limit = params.limit || 10;
  var filter = params.filter || {};
  var offset = params.offset || 0;
  var q = new parse.Query(Facility);

  if ( sort === 'near' ) {
    if ( !(params.lat && params.lon) ) {
      return callbacks.error("Please provide a lat and lon");
    }

    var geopoint = new parse.GeoPoint(params.lat, params.lon);
    q.near('location', geopoint);
  } else {
    q.ascending('name');
  }

  q.limit(limit);
  q.include('services');
  q.skip(offset);

  var resp = [];

  q.find().then(function(results) {
    _.each(results, function(f) { 
      if ( f.matchesFilter(filter) ) { 
        results.push(f);
      }
      offset++;
    });
    callbacks.success({offset: offset, data: results});
  }, function(err) { 
    callbacks.error(err);
  });
};


@@ -1244,24 +1244,55 @@
 (results) %7B%0A
+    var filteredResults = %5B%5D;%0A%0A
     _.each(r
@@ -1312,17 +1312,16 @@
 ion(f) %7B
- 
 %0A      i
@@ -1351,17 +1351,16 @@
 ter) ) %7B
- 
 %0A       
@@ -1360,17 +1360,25 @@
         
-r
+filteredR
 esults.p
@@ -1462,17 +1462,25 @@
 , data: 
-r
+filteredR
 esults%7D)
@@ -1501,17 +1501,16 @@
 n(err) %7B
- 
 %0A    cal

fix bug with browse.js: don't push onto results