fixed memory leak in merge sort