Improved range calibration code for use