refactored to accept categories