Added counter function