tidying up search functionality