implementing mergesort