fixed/updated expand_range script