updated sample code