refactoring category filtering