added a function countTypes()