refactored group creation