buildgroups is so ugly. trying to clean this up