JS for groupings and transactions; not putting into DOM yet