implemented aggregate with keys