fix group function