Corrected error handling.