Adjusted the logging to be conditional