replication function