moved from C++ to C