fix scoping issues