Fixed a bug in document embedding