Add correct exception handling code