small fix to error handling