Fixed code to handle exception