fixing handling of multiple groups