Using millis function

The code below is intended to run a loop that sequentially turns on pins 0, 1, and 2, and after a delay turn on 53 whenever one of these 3 turns on. All 4 pins are connected to LEDs. This works fine. My problem is that whenever the reset switch is pressed and released there is a VERY brief (a small fraction of a second) flash on 53. (There may also be a flash on 0 but since that LED is intended to come on anyway on the first pass through the loop it's hard to see whether it briefly flashes or not.) I tried this with CurrentTime initially set to 0 but that made no difference.
Any suggestions appreciated.

//  Blink_Using_millis_0-2_wShutter

unsigned long OffTime = 2000;
unsigned long DelayBeforeShutterTime = 1000;
unsigned long ShutterTime = 500;
unsigned long PreviousTime = 0;
unsigned long CurrentTime;
unsigned long TotalTime;
int i = 0;

// the setup function runs once when you press reset or power the board
void setup()  {
  
  pinMode(LED_BUILTIN, OUTPUT);  // initialize digital pin LED_BUILTIN as an output
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(53, OUTPUT);
  
  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  digitalWrite(2, HIGH);
  digitalWrite(53, HIGH);

  TotalTime = OffTime + DelayBeforeShutterTime + ShutterTime;
}

// the loop function runs over and over again forever
void loop() {
  CurrentTime = millis();

  if (CurrentTime - PreviousTime >= OffTime)  {
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(i, LOW);    //Turn on LEDi
  }
  if (CurrentTime - PreviousTime >= OffTime + DelayBeforeShutterTime)  
    digitalWrite(53, LOW); 
  if (CurrentTime - PreviousTime >= TotalTime)  {
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(i, HIGH);    //Turn off LEDi
    digitalWrite(53, HIGH);
    PreviousTime = CurrentTime;
    i = ++i;
    if (i >= 3)
      i = 0;  
  }    
 
}

You need to update PreviousTime to CurrentTime whenever an interval elapses. You may need to store multiple “PreviousTime’s”.

Try this:

void setup()  {
 
  pinMode(LED_BUILTIN, OUTPUT);  // initialize digital pin LED_BUILTIN as an output
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(53, HIGH);
  pinMode(53, OUTPUT);
 
  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);
  digitalWrite(2, HIGH);
 
  TotalTime = OffTime + DelayBeforeShutterTime + ShutterTime;
}