new version of function.cpp