Refactor range into sub_array