modify the check of function end