refactor (oops same branch)  and implement mergesort