Switch algorithm for scope matching

Switch algorithm for scope matching. Detailed here Frameworks/scope/tests/design.md