patch toSource function: closure problem