minor changes to error handling