update error calculation