Update tw.cpp