Added a count function