Adds more code to insertDocument