changes to calculate error