Added implemention of the calibrate function