Implement proper variable shadowing in functions