Fixed paring bug in tns.cpp