fixed a scoping bug