Add guards for distinct inside of the aggregate