fix some bug of the function logic

fix some bug of the function logic