reduce code duplication on DOM api