fixing problem with scoping