refactoring sms counter