Now with an optimized C++ version