refactor group checking, a la basta