Fixed scoping bug