Second version, outputs list in HTML or JSON