Need advice on model train controller logic

The spd function is called up in another void but my main focus here was on the logic for train direction. That being said, I just got this working by adding a variable called lastSwitch which identifies the last switch activated. The revised code is below and tested fine.
Anyway, I'm still somewhat confused by the looping characteristics of the Arduino software because it appears that it requires more variables and condition testing to implement in a model train routine as opposed to a sequential program. Am I correct in assuming this? Is there a way around the void loop or is it desirable?

void loop() {

  if (dir == 0)  {   // train in forward direction
    if (bitRead(poll0,4))  {  // reed switch 4 activated
      throttle = 0;     // train coasts to a stop
      lastSwitch = 4;
    }
    if (spd > 0) {  //  start timer when train stops 
      directionTimer = millis() ; 
    }
    if  (millis() - directionTimer >= directionInterval && lastSwitch == 4){ // after 3 seconds
      dir = 1;   // set direction to reverse
      throttle = 50;     // at speed 50
    }
  }
  
  if (dir == 1)  {  // train in reverse direction
    if (bitRead(poll0,5))  { // reed switch 5  activated
      throttle = 0;   // train coasts to a stop
            lastSwitch = 5;
    }
    if (spd > 0) {  //  start timer when train stops
      directionTimer = millis() ; 
    }
    if  (millis() - directionTimer >= directionInterval && lastSwitch == 5){  // after 3 seconds
      dir = 0;   // set direction to forward
      throttle = 100;     // at speed 100
    }
  }
}