implement merge_line