replaced MergeSortTD with a recursive implementation