Refactor aggregate handler to simplify attribute access.