fix function context bug