Slight modification to logging logic