fix infinite recursion problem with reursive_range_fn