fix some bugs in sample code