add merge sort rewrite