adding code up through merge sort