finally i have the correct variable scope