adding motor control logic