polished replication script