optimize the error calculation