clean up range code --- separate into sub-functions
pass replacement references to range mutations