Replaced sums with counts