Wrote the search() function