better re-implementation of the search endpoint.