better logic for looping through categories and publications