cleaned up code and use of new "Range" class