functions filter and search changed

Changed the functions so that it would select from one category at a
time. Also changed the code to use the functions