Refactor dom utils