Functionality for Category filter.
Minor refactoring