refactor and add categories counts