a refactored version of HTMLDomParser