added a count function since it was somehow missing from the lib