refactored to use correct counter