added sms picking logic from mysql