Rewrote merge_pair to ldat