refactory sample code.