added recursion for groups