improved HTML parsing