Added code for swapWithNext