Remove repetition in getting categories