added merge sort and swap variables