solve 'junk element after document' problem