Fixing bug where an exist clause in a nested scope wiped variable out in the outer scope