implementing merge sort