fix undefined nextSibling loop