var scoping fixes