add function to select the number of groups expected