remove dependency on dom, implement hue api, optimize loops by caching lengths