Fixed var scope error