fix some bugs with DOM