replace string/HTML parsing with direct DOM manipulations