added C++ 11; n^3 approach works!