Working version with count.