Corrected bug with exception logging