fix scoping handling