refactor dom events helpers