completed merge sort method