more scoping fixes