Working version of test_2ndpass.cpp