more logic. WIP groups (almost there)