restructure scope_gen init