fix bug in recursive copy