Modify document and undo changes instead of duplicating