replication refactoring