added some threading to motor control