sms function refine