implemented method 'getCountPerCategory'