added calibration code