fixed the sample code to work