refactor domdocument