updated sample code from webinar version