minor fix to error handling