Added a simple counting function