Added calculation for max error