refactored dom functions into a separate namespace