moved calibration code