Refactor _handleGroupLogic