Added motor driving logic