Added a try catch to catch error