changed from C++ to C