Serial version in C++