Fixing error logging