Arduino / Stepper motor / myStepper function

hi,

I am running a stepper motor on a linear guide with one home sensor. my problem is when the Arduino is switched off and on the motor initializes to the home position again from the position it stopped. I need to save the current direction and the position of the stepper when the power is gone.

#this is my current code

#include <Stepper.h>
const int potmeterPin = A0;
int spd = 0;
int sped = 0;
const int buttonPin = 7;
const int ledPin = 13;
const int stepsPerRevolution = 100;
// variables will change:
int buttonState = 0;
int VPin = 2;
int VPinn = 4;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
int stepCount = 0;

void setup() {
Serial.begin(9600);
pinMode(VPin, OUTPUT);
pinMode(VPinn, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(VPin, OUTPUT);
digitalWrite(VPin, HIGH);
digitalWrite(VPinn, HIGH);
}

void loop()
{
buttonState = digitalRead(buttonPin);
spd = analogRead(potmeterPin);
sped = map(spd,0,1023,0,100);
myStepper.setSpeed(sped);
myStepper.step(stepsPerRevolution / 100);

if (buttonState == LOW) {

motorStep();

}
else if (buttonState == HIGH){
myStepper.step(-stepsPerRevolution);
digitalWrite(ledPin, LOW);
Serial.println(-stepsPerRevolution);
Serial.println(sped);

}

}

void motorStep(){

for(int x = 0; x < 300; x++)
{

spd = analogRead(potmeterPin);
sped = map(spd,0,1023,0,100);
myStepper.setSpeed(sped);
myStepper.step(stepsPerRevolution / 100);
myStepper.step(stepsPerRevolution);
digitalWrite(ledPin, HIGH);
Serial.println(stepsPerRevolution);
Serial.println(sped);

}
}