Fixing bug in logging logic