fixed bug with useThisScope and flattenFunctionDefinition