fix crash in example when selecting a new range next to the existing one (range1 or range2 will then be null)