tweaks to error handling