fixes errors in search method