made the inserting of document generic