small changes in Replicate()