cleanup the error handling