sms logic