Improve c++ version of thr converter