add the function of grouping