fixes errors in search method

There were some errors in the search function migration. This edit should fix them.