refactor sms module code