handle exception; bug fix