refactoring for group selection