updated the index function to handle a search query and render page containing query.