Refactoring event count api