Added extra checks when copying files