fix error handling.