Fix nested functions variable access