fix a bug in func.cpp