Fixed the issue with exception handling