minor improvement on document insert