Updated Exception handling code.