Try this concept:
while(digitalRead(CWPin){ stepMotorCW; } while(digitalRead(CCWPin){ stepMotorCCW; }