UPDATED error handling.