inital code for stopThreshold