created function to control motor functions