updated merge sort algorithm