rewite sample codes