modified tc3.cpp