merge-sentence implementation