refining scratch replication script