MIllis , int not refresh value

I could send the whole code, but it would bring unnecessary confusion.
I have prepared a cod that shows my problem. the value in int changes, but is not loaded and changes in "periods"

int val1=1000;
int val2=1000;

const byte ledPins[] = {12, 13};
unsigned long periods[] = {val1, val2};
byte index = 0;
unsigned long startTime;
unsigned long currentTime;



 void setup()
 {      pinMode(ledPins[0], OUTPUT);
  pinMode(ledPins[1], OUTPUT);
     Serial.begin(9600); // baud rate
    Serial.flush();
 }
 
 void loop()
 {
     String input = "";
 
     // Read any serial input
     while (Serial.available() > 0)
    {
        input += (char) Serial.read(); // Read in one char at a time
         //delay(5); // Delay for 5 ms so the next char has time to be received
     }
 
     if (input == "+")
     {val2=3000;
       
     }
     else if (input == "-")
     {
        val2=200;
     }
 currentTime = millis();
  if (currentTime - startTime >= periods[index])
  {
    digitalWrite(ledPins[index], LOW);
    index++;
    index = index % 2;
    digitalWrite(ledPins[index], HIGH);
    startTime = currentTime;
  }

    Serial.println(val1);
 }