Improved the exception catching feature