revamp how grouping works and tests