refactoring code for motor direction config

working on fixing a bug with the direction switching synchronization