modified project2.cpp