implemented merge sort