moved order of copying files to avoid error