fixed the case where the document begins with a paragraph