implemented swapElements method
update