Added the swapping code in the data structure (client side)