categories.js refactor