Fixed bug in __aggr function