Error handling code fix