add sample code and fix some code