uses {} instead of new Object(), it's faster
uses .hasChildNodes()
added Array.forEach