a bit of refactoring; improved handling of search vs. single resource request