diff --git a/bin/main.out b/bin/main.out
index b621e44b2d756e9806f23b9b9edbd2ed5a304caf..82d3cb1f4c796b85ca2eab5aff4e9dfa5af9d0bd 100755
Binary files a/bin/main.out and b/bin/main.out differ
diff --git a/src/main.cmi b/src/main.cmi
index 740246282506ff6bb6ff4cde753d15e271ac7c5e..178c9b9fe588ef148fc085b95dd6a294c3ae0dc4 100644
Binary files a/src/main.cmi and b/src/main.cmi differ
diff --git a/src/main.cmx b/src/main.cmx
index 5579100a531f037badfa5f20ae82afb22802bfc6..13de27bd754c1204578804df7bfcf1214c5e227f 100644
Binary files a/src/main.cmx and b/src/main.cmx differ
diff --git a/src/main.ml b/src/main.ml
index db6e005438c7622dc98244e8138e6037f65bfac3..22f63afbe92a3df9bda54f679f9e597bdb75d92d 100644
--- a/src/main.ml
+++ b/src/main.ml
@@ -120,18 +120,20 @@ let rec make_liste_index l c = match l with
  * @ensure : renvoi l'indice de la roue (dans la liste de roues l) avec laquelle il est plus rapide de traduire c
  *)
 let quelle_roue l c index_init =
-    let index = (char_to_index 0 c roue) in
-    let m = (if index < 14 then index else 27-index) in
-    let test = char_to_index 0 c (List.nth l index_init) in
-    let test_opt = (if test < 14 then test else 27-test) in 
-    if (test_opt <= m) then index_init else 
-    (*i doit être 0 lors du premier appel*)
+    let index = (char_to_index 0 c (List.nth l index_init)) in
+    let m = (if index < 14 then index else 27-index) in 
+    (*
+     * i doit être 0 lors du premier appel
+     * m est le decalage (gauche ou droite) à faire pour trouver c
+     * r est la liste des décalages pour chaque roue
+     * n est l'indice du min des décalages de i0 à i
+     * *)
     let rec index_min m n i r =  match r with
         | [] -> n
         | e::t -> if e < 14 then (if e < m then (index_min e i (i+1) t) else index_min m n (i+1) t)
                   else (if 27-e < m then (index_min (27-e) i (i+1) t) else index_min m n (i+1) t)
     in 
-    index_min m (List.length l) 0 (make_liste_index l c);;
+    index_min m index_init 0 (make_liste_index l c);;
 
 
 (*
@@ -144,21 +146,31 @@ let rec tourner_list c n i l =
         | e::t -> if i = 0 then  (List.append ((tourner c n e)::[]) t)
         else (List.append (e::[]) (tourner_list c n (i-1) t));;
 
+(*
+ * initialise une liste de taille n entièrement remplie avec un élément a
+ *)
+let rec initialize_list n a = if n = 1 then [a] else if n = 0 then [] else a::(initialize_list (n-1) a);; 
+
 (* 
  * @ensure : traduit le message l en commande en selectionnant pour chaque lettre la bonne antenne
  *)
-let rec commande_phase2 (i,l) liste_roues index_init = match l with
+let commande (n,m) = 
+let rec commande_phase2 l liste_roues index_init = match l with
     | [] -> ""
     | e::t -> let index = quelle_roue liste_roues e index_init in
-              let r = (if index = (List.length liste_roues) then roue else (List.nth liste_roues index)) in
-              let (s,n) = translate e r in
-              let sres = (if index = index_init then s else (String.concat "" ("S"::(string_of_int index)::s::[])) ) in
-              let new_liste = tourner_list s.[0] n index liste_roues in
-              Printf.printf "%d\n" index;
-              String.concat "" (sres::(commande_phase2 (i,t) new_liste index)::[]);;
+              let r = (List.nth liste_roues index) in
+              let (s,i) = translate e r in
+              let sres = (if index = index_init then s else ("S"^(string_of_int index)^s)) in
+              let new_liste = tourner_list s.[0] i index liste_roues in
+              (*Printf.printf "%d\n" index;*)
+              sres^(commande_phase2 t new_liste index)
+in
+    let liste = initialize_list n roue
+    in
+    commande_phase2 m liste 0;;
 
 (*@ensure : test commande_phase 2*)
-let com2 = commande_phase2 input liste_roues 0;;
+let com2 = commande input;;
 print_string com2;;
 Printf.printf "\n %d s \n" (temps_commande com2);;
     
diff --git a/src/main.o b/src/main.o
index 0a62970799e3ee2c10c248a4405ae5131139e29c..4172f69bb1296de92e33eb2d25628e31d912df19 100644
Binary files a/src/main.o and b/src/main.o differ