Reorganize dom functions