c++ wrapper refactor