more error handling improvements