Fix variable shadowing bug