support for different number of motors

control flow using switch instead of for loop