Adding mergesort logic