added end document/fixed preamble