You may try this approach:
AlekseyL
212

AlekseyL, this is a mind blower. All the scoping and ransacker code can simply be replaced by this no-brainer piece of code. Code can be amaizing sometimes.