Stepper driver steps not accurate

I retraced my wiring and connected to the NC terminal on the switch instead of the NO and it doesn't operate randomly any more, not sure why that matters but I will search it and try to learn why.
Thanks for the help Robin2.

Here's the program just in case.

#include <AccelStepper.h>

AccelStepper stapler(AccelStepper::DRIVER, 5, 6);

const int button = 2;            // pin button is on
int val = 0;                     // current button state
int old_val = 0;
int buttonstate = 0;
unsigned long previousMillis = 0;

void setup() {

  pinMode(button, INPUT_PULLUP);
  stapler.setMaxSpeed(1000);
  stapler.setAcceleration(6000);

}

void loop() {

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 100) {
    val = digitalRead(button);
    if ((val == LOW) && (old_val == HIGH)) {
      buttonstate = 1;
    }
    previousMillis = currentMillis;
    old_val = val;
  }
  if (buttonstate == 1) {
    stapler.move(400);
    buttonstate = 0;
  }

  stapler.run();
}