Refactor to use DOM API instead of embedded HTML strings