bug fix for set_function