created example code from main.cpp