added a try-catch block