diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go
index 80ff952f0f1c9749e364224a68913033d293b9b0..fa700388c6330a7fc29fe4aaf3df10ffab73d7b4 100644
--- a/plugins/analysis/webinterface/recordedevents/recorded_events.go
+++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go
@@ -76,6 +76,9 @@ func Configure(plugin *node.Plugin) {
 }
 
 func Replay(handlers *types.EventHandlers) {
+	lock.Lock()
+	defer lock.Unlock()
+
 	for nodeId, online := range nodes {
 		handlers.AddNode(nodeId)
 		if online {
@@ -84,8 +87,7 @@ func Replay(handlers *types.EventHandlers) {
 			handlers.NodeOffline(nodeId)
 		}
 	}
-	lock.Lock()
-	defer lock.Unlock()
+
 	for sourceId, targetMap := range links {
 		for targetId := range targetMap {
 			handlers.ConnectNodes(sourceId, targetId)