Updating reference to document to window