improved error handling.