fixed insertDocument