added stats related functions to create and handle groupings