diff --git a/src/Cluster.hs b/src/Cluster.hs
index 0247e6a55dc3599741f3bf957961efedac8bf3fd..84944917fe9dc1a4e0045b0970b5b606518c62f2 100644
--- a/src/Cluster.hs
+++ b/src/Cluster.hs
@@ -23,6 +23,7 @@ module Cluster
     , applySolution
     , printSolution
     , printSolutionLine
+    , formatCmds
     , printNodes
     -- * Balacing functions
     , checkMove
@@ -569,6 +570,13 @@ printSolutionLine il ktn kti nmlen imlen plc =
        pmlen nstr c moves,
        cmds)
 
+formatCmds :: [[String]] -> String
+formatCmds cmd_strs =
+    unlines $ map ("  echo " ++) $
+    concat $ map (\(a, b) ->
+        (printf "step %d" (a::Int)):(map ("gnt-instance" ++) b)) $
+        zip [1..] cmd_strs
+
 {-| Converts a solution to string format -}
 printSolution :: InstanceList
               -> [(Int, String)]
diff --git a/src/hbal.hs b/src/hbal.hs
index 352fbb4b7910735f2662cd7553b49ba11eebf674..06d85c534b7703765163c368ca9b17fd46dbfbe2 100644
--- a/src/hbal.hs
+++ b/src/hbal.hs
@@ -185,8 +185,7 @@ main = do
        do
          putStrLn ""
          putStrLn "Commands to run to reach the above solution:"
-         putStr $ unlines $ map ("  echo gnt-instance " ++)
-                    $ concat $ reverse cmd_strs
+         putStr . Cluster.formatCmds . reverse $ cmd_strs
   when (optShowNodes opts) $
        do
          let (orig_mem, orig_disk) = Cluster.totalResources nl
diff --git a/src/hn1.hs b/src/hn1.hs
index cb8439247e38f893a7b24debad9f8a9fde540030..5506e8aa0331eef465c93be6624f7e1337b18c62 100644
--- a/src/hn1.hs
+++ b/src/hn1.hs
@@ -187,7 +187,8 @@ main = do
        do
          putStrLn ""
          putStrLn "Commands to run to reach the above solution:"
-         putStr $ unlines $ map ("  echo gnt-instance " ++) $ concat cmd_strs
+         putStr . Cluster.formatCmds . reverse $ cmd_strs
+
   when (optShowNodes opts) $
        do
          let (orig_mem, orig_disk) = Cluster.totalResources nl