bug fix in top_level_scopes

correctly handle done set