corrected the error calculation