report tool: refactor aggregate functions