copy do-region from old code