basic replication code