Fix scoping bug