improve from function so that it takes a range instead of two iterators (same semantics as range-based for loop)