Added a try-catch for additional safety.