def METHOD_NAME(message_sid, message_status):
    """The function checks existence of SMSMessage
    instance according to message_sid and updates status on
    message_status
    Args:
        message_sid (str): sid of Twilio message
        message_status (str): new status
    Returns:
    """
    from apps.base.models import UserNotificationPolicyLogRecord
    if message_sid and message_status:
        logger.info(f"twilioapp.update_twilio_message_status: processing sid={message_sid} status={message_status}")
        status_code = TwilioSMSstatuses.DETERMINANT.get(message_status)
        if status_code is None:
            logger.warning(
                f"twilioapp.update_twilio_message_status: unexpected status sid={message_sid} status={message_status}"
            )
            return
        twilio_sms = TwilioSMS.objects.filter(sid=message_sid).first()
        if twilio_sms is None:
            logger.warning(f"twilioapp.update_twilio_message_status: twilio_sms not found sid={message_sid}")
            return
        logger.info(f"twilioapp.update_twilio_sms_status: found twilio_sms sid={message_sid}")
        twilio_sms.status = status_code
        twilio_sms.save(update_fields=["status"])
        sms_record = twilio_sms.sms_record
        if sms_record is None:
            logger.warning(f"twilioapp.update_twilio_sms_status: twilio_sms has no sms_record sid={message_sid}")
            return
        logger.info(
            f"twilioapp.update_twilio_sms_status: found sms_record id={sms_record.id} "
            f"sid={message_sid} status={message_status}"
        )
        log_record_type = None
        log_record_error_code = None
        if status_code == TwilioSMSstatuses.DELIVERED:
            log_record_type = UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_SUCCESS
        elif status_code in [TwilioSMSstatuses.UNDELIVERED, TwilioSMSstatuses.FAILED]:
            log_record_type = UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_FAILED
            log_record_error_code = get_sms_error_code_by_twilio_status(status_code)
        if log_record_type is not None:
            log_record = UserNotificationPolicyLogRecord(
                type=log_record_type,
                notification_error_code=log_record_error_code,
                author=sms_record.receiver,
                notification_policy=sms_record.notification_policy,
                alert_group=sms_record.represents_alert_group,
                notification_step=sms_record.notification_policy.step if sms_record.notification_policy else None,
                notification_channel=sms_record.notification_policy.notify_by
                if sms_record.notification_policy
                else None,
            )
            log_record.save()
            logger.info(
                f"twilioapp.update_twilio_sms_status: created log_record log_record_id={log_record.id} "
                f"type={log_record_type}"
            )
            user_notification_action_triggered_signal.send(sender=METHOD_NAME, log_record=log_record)