error handling improvements