diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index 1c77b18..109ae98 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -252,56 +252,53 @@ replication_run(void)
                 }
                 ovsdb_schema_destroy(schema);
 
-                /* After receiving schemas, reset the local databases that
-                 * will be monitored and send out monitor requests for them. */
+                /* After receiving schemas, send out monitor requests for DB. */
                 if (hmap_is_empty(&request_ids)) {
-                    struct shash_node *node, *next;
-
-                    SHASH_FOR_EACH_SAFE (node, next, replication_dbs) {
+                    struct shash_node *node;
+                    SHASH_FOR_EACH (node, replication_dbs) {
                         db = node->data;
-                        struct ovsdb_error *error = reset_database(db);
-                        if (error) {
-                            const char *db_name = db->schema->name;
-                            shash_find_and_delete(replication_dbs, db_name);
-                            ovsdb_error_assert(error);
-                            VLOG_WARN("Failed to reset database, "
-                                      "%s not replicated.", db_name);
-                        }
-                    }
-
-                    if (shash_is_empty(replication_dbs)) {
-                        VLOG_WARN("Nothing to replicate.");
-                        state = RPL_S_ERR;
-                    } else {
-                        SHASH_FOR_EACH (node, replication_dbs) {
-                            db = node->data;
-                            struct ovsdb *db = node->data;
-                            struct jsonrpc_msg *request =
-                                create_monitor_request(db);
-
-                            request_ids_add(request->id, db);
-                            jsonrpc_session_send(session, request);
-                            VLOG_DBG("Send monitor requests");
-                            state = RPL_S_MONITOR_REQUESTED;
-                        }
+                        struct ovsdb *db = node->data;
+                        struct jsonrpc_msg *request =
+                            create_monitor_request(db);
+
+                        request_ids_add(request->id, db);
+                        jsonrpc_session_send(session, request);
+                        VLOG_DBG("Send monitor requests");
+                        state = RPL_S_MONITOR_REQUESTED;
                     }
                 }
                 break;
             }
 
             case RPL_S_MONITOR_REQUESTED: {
-                /* Reply to monitor requests. */
-                struct ovsdb_error *error;
-                error = process_notification(msg->result, db);
+                /* After receiving monitor response, reset the local database
+                 * that will be monitored and process message. */
+                struct ovsdb_error *error = reset_database(db);
                 if (error) {
+                    const char *db_name = db->schema->name;
+                    shash_find_and_delete(replication_dbs, db_name);
                     ovsdb_error_assert(error);
+                    VLOG_WARN("Failed to reset database, "
+                              "%s not replicated.", db_name);
+                }
+
+                if (shash_is_empty(replication_dbs)) {
+                    VLOG_WARN("Nothing to replicate.");
                     state = RPL_S_ERR;
                 } else {
-                    /* Transition to replicating state after receiving
-                     * all replies of "monitor" requests. */
-                    if (hmap_is_empty(&request_ids)) {
-                        VLOG_DBG("Listening to monitor updates");
-                        state = RPL_S_REPLICATING;
+                    /* Reply to monitor requests. */
+                    struct ovsdb_error *error;
+                    error = process_notification(msg->result, db);
+                    if (error) {
+                        ovsdb_error_assert(error);
+                        state = RPL_S_ERR;
+                    } else {
+                        /* Transition to replicating state after receiving
+                         * all replies of "monitor" requests. */
+                        if (hmap_is_empty(&request_ids)) {
+                            VLOG_DBG("Listening to monitor updates");
+                            state = RPL_S_REPLICATING;
+                        }
                     }
                 }
                 break;
