improved array element swaps