Optimized Implementation of Merge Sort