How do I get rid of duplication

I will add a field to the struct and get rid of "for future use". I've been kinda avoiding pointers for now. I can see how useful it would be in this case.

Right now, I'm trying to find out why the relays associated with Pwm1 are chattering in only one of their servo positions. They were working properly with the same data using my old code, so I'm trying to figure out what happened. Relays associated with Pwm0 appear to work fine with the correct feedback to the JMRI computer.

  for (int i = 0; i < turnArrayLength; i++) {
    
    turnArray[i].targetPos = (cmri.get_bit(i) == 1) ? turnArray[i].pos1 : turnArray[i].pos2;
    if (turnArray[i].targetPos != turnArray[i].currentPos) {
...
    turnArray[i].relayState = (turnArray[i].currentPos == turnArray[i].pos1) ? turnArray[i].relayState1 : !turnArray[i].relayState1;
    cmri.set_bit( i , turnArray[i].relayState );
    digitalWrite(turnArray[i].relayPin, turnArray[i].relayState);
  }

I can't see any reason why values of i > 15 would cause a problem with the relay lines.

Thanks,

Mandy