Refactoring badge count