fix for vars used out of scope