Refactoring: do the count calculation outside the site plugin.