add try catch to handle exception