variable changing unexpectedly in program, except if adding a Serial.println()