added grouping function as option