number of categories was getting the wrong value