Added exception handler code