scoping fixes