Implemented in c++