fix rearranging logic to be inserting instead of swapping