handle the error case more safely