html processing refactor