First version of calibration routine