Moved exception logging to try-catch block