replaced swapping with shifting