similar solution merge sort