slight update to error handling