updated sample.cpp