changed to a merge sort solution