sample code modified