loop based on categories