count mega refactor