variable scope now working
works
fixed variable scope