updated motion control logic