Move Redrex Stepper Motor using Accel

Dears, I am connecting a stepper motor to arduino Mega, and I am trying to set the stepper mottor position to 100 when pressing to c and when it's in the position 100 I want to return to the default position which is 0. However it is not working. Stepper motor is moving few steps slowly and do not get to the normal position. Kindly help

while (input_m=='c') {
stepperM.stop();
stepperT.moveTo(100);
stepperT.setSpeed(200);
stepperT.runSpeedToPosition();

if (stepperT.targetPosition()==100) {
stepperM.setSpeed(-motorSpeed_m);
stepperM.moveTo(-steps_inv_m);
stepperM.runToPosition();
stepperT.moveTo(0);
stepperT.setSpeed(200);
stepperT.runSpeedToPosition();
input_m= '0';

 Serial.print("Finish \n");
 Serial.println("");
 break;

}

}

Post all of the code. There is important information in the missing parts. Read the forum guidelines to see how to properly post code.

Describe what you want the code to do, in detail.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Post a schematic of your wiring. Include all components and their part numbers and/or values. Include all power supplies. Here is a tutorial on making a schematic that you can post.

Post a data sheet for the stepper motor and the stepper motor driver.

When we have enough information then we can give intelligent assistance.