implement the visitor counter in a sane way