reduce memory consumption in implemenration of MergeSort