Update and fix sample code