modified sample code and document