createGroup helper method
c++ implementation of grouping