Add feature to count the number of occurrences of an element