foreach_range
Instead of using `to_ranges` and then iterating, we just iterate over the ranges directly.