refactor to standard c++