final commit. still could use rewrite to eliminate for() loops in favor of summarize().