       // stop if button pressed while in motion
       if (swTrigger == LOW) {
         motorFree(); // TODO: motorBrake() might be better for an emergency stop. doesn't make much different in our case, the belt skips and the door stops in both cases
-        Serial.print(currentMillis);
-        Serial.print(F(" Button switch triggered - door blocked\r\n"));
+        debug(currentMillis, F("Button switch triggered - door blocked\r\n"));
         setLeds1(red, ledSolid);
         doorState = doorBlocked;
 swTrigger = HIGH;
         break;
       }
 
+      driveTotalMillis += elapsedMillis;
       driveStepMillis += elapsedMillis;
-      driveTotalMillis += elapsedMillis;
       if (driveStepMillis >= accelProfile[accelProfileIdx].stepMillis) {
         driveMillis += driveStepMillis;
         driveStepMillis = 0;

  // assume that none of the following intervals overflow

/*
  Serial.print(F("Elapsed millis: "));
  Serial.println(elapsedMillis);
*/



      openMillis += elapsedMillis;
      if (openMillis >= openInterval || swBack == HIGH) {
        if (swBack == HIGH) {
          // maybe someone tried to pull the door closed
          // TODO: or the door slams too fast into the end-stop and rebounds. align profile & inertial reality
          debug(currentMillis, F("Back switch triggered - closing door\r\n"));
          initDrive(forward, accelProfileLow);
        } else {
          debug(currentMillis, F("openInterval timeout - closing door\r\n"));
          initDrive(forward, accelProfileHigh);
        }
        setLeds2(white, black, 3, ledForward);
