some changes to sample.cpp and new