modify method of getting number of tags in the document tree