added scale distance formula to calculate error