smaller changes to error handling