added -x switch to turn off at end of run