added input switch to stop core