fixed bad scoping bug