apter rewritten on c++