small refactoring of merge sort