Changing document and adding directives