Added Document tag, and fixed appending