Wrap the document, and handle null