Added a general exception handling