fix static scoping bug