added algorithm to TwBar.cpp, needed for vs2013