adds occurrences method to collection class