added a close() call after document added