splitRanges rewritten