         max += 8;
     }
     int pin = 0;
-    for (int i = 0; i < random(5, max); i++) {
-        if (i % random(1, max / 3) == 0) {
-            if (flickerLetters == 1 && flickerBackground == 1) {
-                pin = random(0, 2) == 0 ? letters[random(0, sizeof(letters))] : background[random(0, sizeof(background))];
-            } else if (flickerBackground == 1) {
-                pin = background[random(0, sizeof(background))];
-            } else {
-                pin = letters[random(0, sizeof(letters))];
-            }
+
+    if (i % random(1, max / 3) == 0) {
+        if (flickerLetters == 1 && flickerBackground == 1) {
+            pin = random(0, 2) == 0 ? letters[random(0, sizeof(letters))] : background[random(0, sizeof(background))];
+        } else if (flickerBackground == 1) {
+            pin = background[random(0, sizeof(background))];
+        } else {
+            pin = letters[random(0, sizeof(letters))];
         }
-
-        digitalWrite(pin, PATTERN_OFF);
-        delay(random(minimal / 2, minimal));
-        digitalWrite(pin, PATTERN_ON);
-        delay(ish);
+    }
+
+    digitalWrite(pin, PATTERN_OFF);
+    delay(random(minimal / 2, minimal));
+    digitalWrite(pin, PATTERN_ON);
+    delay(ish);
+
+    if (repeatCount > 0) {
+        _flickerPattern(flickerLetters, flickerBackground, repeatCount - 1);
     }
 }
 

void setup() {
    randomSeed(analogRead(0));

    for (int i = 0; i < sizeof(Lights); i++) {
        pinMode(Lights[i], PATTERN_INITIALIZE);
    }
}

// code above the man is ignored by the emulator

    classicBackground();
}

void _runTracer() {
  
}

void runTracer() {
    digitalWrite(background[0], PATTERN_ON); delay(none);
    digitalWrite(background[1], PATTERN_ON); delay(none);
    digitalWrite(background[2], PATTERN_ON); delay(none);
    digitalWrite(background[3], PATTERN_ON); delay(none);
    digitalWrite(background[4], PATTERN_ON); delay(none);
    digitalWrite(background[5], PATTERN_ON); delay(none);

    digitalWrite(letters[0], PATTERN_ON); delay(250); digitalWrite(letters[0], PATTERN_OFF); delay(250);
    digitalWrite(letters[1], PATTERN_ON); delay(250); digitalWrite(letters[1], PATTERN_OFF); delay(250);
    digitalWrite(letters[2], PATTERN_ON); delay(250); digitalWrite(letters[2], PATTERN_OFF); delay(250); 
    digitalWrite(letters[3], PATTERN_ON); delay(250); digitalWrite(letters[3], PATTERN_OFF); delay(250);
    digitalWrite(letters[4], PATTERN_ON); delay(250); digitalWrite(letters[4], PATTERN_OFF); delay(250);
    digitalWrite(letters[5], PATTERN_ON); delay(250); digitalWrite(letters[5], PATTERN_OFF); delay(250);
    digitalWrite(letters[6], PATTERN_ON); delay(250); digitalWrite(letters[6], PATTERN_OFF); delay(250);
    digitalWrite(letters[7], PATTERN_ON); delay(250); digitalWrite(letters[7], PATTERN_OFF); delay(250);
    digitalWrite(letters[8], PATTERN_ON); delay(250); digitalWrite(letters[8], PATTERN_OFF); delay(250);
    
    digitalWrite(Lights[0], PATTERN_ON); delay(none); 
    digitalWrite(Lights[1], PATTERN_ON); delay(none); 
    digitalWrite(Lights[2], PATTERN_ON); delay(none); 
    digitalWrite(Lights[3], PATTERN_ON); delay(none); 
    digitalWrite(Lights[4], PATTERN_ON); delay(none); 
    digitalWrite(Lights[5], PATTERN_ON); delay(none); 
    digitalWrite(Lights[6], PATTERN_ON); delay(none); 
    digitalWrite(Lights[7], PATTERN_ON); delay(none); 
    digitalWrite(Lights[8], PATTERN_ON); delay(none); 
    delay(250);
    digitalWrite(Lights[0], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[1], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[2], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[3], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[4], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[5], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[6], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[7], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[8], PATTERN_OFF); delay(none); 
    delay(250);
    digitalWrite(Lights[0], PATTERN_ON); delay(none); 
    digitalWrite(Lights[1], PATTERN_ON); delay(none); 
    digitalWrite(Lights[2], PATTERN_ON); delay(none); 
    digitalWrite(Lights[3], PATTERN_ON); delay(none); 
    digitalWrite(Lights[4], PATTERN_ON); delay(none); 
    digitalWrite(Lights[5], PATTERN_ON); delay(none); 
    digitalWrite(Lights[6], PATTERN_ON); delay(none); 
    digitalWrite(Lights[7], PATTERN_ON); delay(none); 
    digitalWrite(Lights[8], PATTERN_ON); delay(none); 
    delay(250);
    digitalWrite(Lights[0], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[1], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[2], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[3], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[4], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[5], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[6], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[7], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[8], PATTERN_OFF); delay(none); 
    delay(250);
    digitalWrite(Lights[0], PATTERN_ON); delay(none); 
    digitalWrite(Lights[1], PATTERN_ON); delay(none); 
    digitalWrite(Lights[2], PATTERN_ON); delay(none); 
    digitalWrite(Lights[3], PATTERN_ON); delay(none); 
    digitalWrite(Lights[4], PATTERN_ON); delay(none); 
    digitalWrite(Lights[5], PATTERN_ON); delay(none); 
    digitalWrite(Lights[6], PATTERN_ON); delay(none); 
    digitalWrite(Lights[7], PATTERN_ON); delay(none); 
    digitalWrite(Lights[8], PATTERN_ON); delay(none); 
    delay(250);
    digitalWrite(Lights[0], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[1], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[2], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[3], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[4], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[5], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[6], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[7], PATTERN_OFF); delay(none); 
    digitalWrite(Lights[8], PATTERN_OFF); delay(none); 
    delay(250);
    delay(250);
}

void runLetterPattern() {
    // if new patterns are added, add a new case statement, and bump up the max random value by one
    switch (random(0, 2)) {
    case 0: { lettersOnLeftToRight(); break; }
    case 1: { blinkLetters(random(5, 10)); break; }
    // case 2: {  blinkLettersOnRandom(); break; }
    default: { break; }
    }
}

void runBackgroundPattern() {
    switch (random(0, 4)) {
    case 0: { classicBackground(); break; }
    case 1: { insideOutOutsideInBackground(); break; }
    case 2: { racingOnLeftToRightBackground(); break; }
    case 3: { blinkBackground(random(5, 10)); backgroundAllOn(); break; }
//    case 4: { blinkBackgroundOnRandom(); break; }
    }
}

