added max and minSquare variabes.
Starting to implement calibration function