fix scope nesting