creating function to render the search properly