Bug fix for counting()