add exception handling code