Optimalisation of the CreateGroupFunction