program for 3 ways switch

hello seniors.. I want to ask a question regarding the coding for the 3 ways switch "ON (cw) OFF ON (ccw)' for the stepper motor movement. my problem is when i hit the right button, it moves cw, it was okay for me. then i hit center button and it should off, but it rotates ccw. when i hit the other sides button, it then stop. my question is, is there something wrong in programming or the wiring? if some of you can share some knowledge for this, i would be greatly thankful.

My crystal ball isn't working very well but, check your wiring.
I am old but not a senior!

Imgur