refactored EfficientMergeSort