move the dom related functionality into a separate class