HTML DOM building improvement