relocated counter function