Identical code to code in `group_by`. Could be made a function / property