fix a bug in sample code