modified sample code