Implementing merge sort