refactoring to use Count