If you use the AutoFormat feature to indent your code consistently you will have a much better sense of what parts go together - for example what code is encompassed by an IF or an ELSE.
Don't insert unnecessary braces {} such as here
{ stepper.run(); }
And if you only have one motor you only need stepper.run() in one place - usually the last item in loop() and NOT inside any IF or WHILE.
If that does not help please post the latest version of your program properly formatted.
...R