Updated style function to take categories into account