refactored dom.js