Revised sample code