code from accelerated c++