cleaned up scoping