added expand ranges function