using booleans for the mode and value change detector.