3 times XOR operaton for swapping two variables
moved swap functionality in to function