Count occurences in an object oriented way