Correcting error handling