Refactored `getCategory` to @eko's suggestions