Added a try/catch block of code to handle the exception created