added group and permutation handling