C++ version now works!