update for var scope problems
update for var scope problems