added motor control function