turn categories into a funciton