fixed sample code runtime errors