Added a check to turn on logging