Corrected bug in sample code