Fix Junction and grouping logic