optimize context scope chain