Case switch instead of if statement

hun1:
But I have to press both the button and limiter switch at the same time to make the motor move to the specified location.

That is because your if test for the limit switch is inside the if condition for the button, i.e. it only tests the limit switch if the button is pressed. Separate the ifs & you should be good to go.