replication need refactor