`nbCategories` should be defined before if and used line 76