Add replication code