Fix crash in evaluating functions