refactored replaceWithDelay function, renamed Dom object literal
rearrage functions, remove whitespace