diff --git a/aql2/src/REPL.cpp b/aql2/src/REPL.cpp
index b875d010b13d2f7b5c42a4303b2b1083470a8c62..37c5bdc6ce5d9fa9febfb19711ec8eba7f06c069 100644
--- a/aql2/src/REPL.cpp
+++ b/aql2/src/REPL.cpp
@@ -118,10 +118,10 @@ cli::CommandResult REPL::run(cli::Environment& env)
         if (input.empty()) {
             continue;
         }
+        rx.history_add(input);
+
         try {
             state = env.execute(input);
-            if (state == cli::CommandResult::OK)
-                rx.history_add(input);
         } catch (const std::exception& e) {
             std::cerr << e.what() << '\n';
         }