fixing logic for categories