moved more of the search handling into the api