cache the scope chain on the stack and eliminate `i`