minh's calibration code