porting to new top_level_scopes API