fixed error code handling