fix bug in replication