revised main.cpp