Fix total document bug