Optimizes mergeSort