fixed error calculations