refactored category processing