add some codes to handle exception