fixed grouping functionality