clean up aggregate code