improve error handling.