copy function changed for binary copying