Stepper driver steps not accurate

I guess that's why you guys get the big bucks, it was code related but I still have a problem getting it to act the same as my old code. I can run the stepper only once with the press of the button and then have to hit reset on the controller to make it move again with the button press using the Accelstepper.h library. On the stepper.h library I just changed the state at the end of the program and then was able to press the button to start everything again, but if I write state = 0 at the end of the program I can feel the motor shutter ever so slightly but not run to a position. I'm not sure why it would be any different but hopefully someone can point me in the right direction.
Thanks

#include <AccelStepper.h>

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

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


void setup() {

  pinMode(button, INPUT_PULLUP);
  tableSlider.setMaxSpeed(1000);
  tableSlider.setAcceleration(400);
}

void loop() {
  val = digitalRead(button);                    // read input value and store it
  unsigned long currentMillis = millis();       //check for current time


  //give time for debouncing
  if (currentMillis - previousMillis >= 100) {

    if ((val == LOW) && (old_val == HIGH)) {
      state = 1 - state;                    // change the state
    }
    previousMillis = currentMillis;         // save the last time the button was ptressed

    old_val = val;                       // val is now old, let's store it
  }
  if (state == 1) {
    tableSlider.moveTo(-400);
    tableSlider.run();
    //state = 0;
  }

}