Fixed using of wrong document bug