improved/fixed the routine to find named groups