improved groups handling