diff --git a/helpers/Dojo/ExerciseDockerCompose.ts b/helpers/Dojo/ExerciseDockerCompose.ts
index dafa4bdc8690fff4bbb74b02e8a0340c686d9b70..9dd619ce9af09956e8054ad2a3a08583044dde72 100644
--- a/helpers/Dojo/ExerciseDockerCompose.ts
+++ b/helpers/Dojo/ExerciseDockerCompose.ts
@@ -44,6 +44,10 @@ class ExerciseDockerCompose {
         this.events.emit('logs', message, error, displayable, this.currentStep);
     }
 
+    private finished(success: boolean, code: number) {
+        this.events.emit('finished', success, code);
+    }
+
     private registerChildProcess(childProcess: ChildProcessWithoutNullStreams, resolve: (value: (number | PromiseLike<number>)) => void, reject: (reason?: unknown) => void, displayable: boolean) {
         childProcess.stdout.on('data', (data) => {
             this.log(data.toString(), false, displayable);
@@ -86,7 +90,7 @@ class ExerciseDockerCompose {
                     });
                 } catch ( error ) {
                     this.endStep(`Error while running the docker compose file`, true);
-                    this.events.emit('finished', false, ExerciseCheckerError.DOCKER_COMPOSE_RUN_ERROR);
+                    this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_RUN_ERROR);
                     return;
                 }
                 this.endStep(`Docker Compose file run successfully`, false);
@@ -110,7 +114,7 @@ class ExerciseDockerCompose {
                     });
                 } catch ( error ) {
                     this.endStep(`Error while getting the linked services logs`, true);
-                    this.events.emit('finished', false, ExerciseCheckerError.DOCKER_COMPOSE_LOGS_ERROR);
+                    this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_LOGS_ERROR);
                     return;
                 }
                 this.endStep(`Linked services logs acquired`, false);
@@ -135,10 +139,10 @@ class ExerciseDockerCompose {
                         });
                     } catch ( error ) {
                         this.endStep(`Error stop and remove containers`, true);
-                        this.events.emit('finished', false, ExerciseCheckerError.DOCKER_COMPOSE_DOWN_ERROR);
+                        this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_DOWN_ERROR);
                         return;
                     }
-                    this.events.emit('endStep', this.currentStep, `Containers stopped and removed`, false);
+                    this.endStep(`Containers stopped and removed`, false);
                 }
             }
 
@@ -161,14 +165,14 @@ class ExerciseDockerCompose {
                         });
                     } catch ( error ) {
                         this.endStep(`Error while removing dangling images`, true);
-                        this.events.emit('finished', false, ExerciseCheckerError.DOCKER_COMPOSE_REMOVE_DANGLING_ERROR);
+                        this.finished(false, ExerciseCheckerError.DOCKER_COMPOSE_REMOVE_DANGLING_ERROR);
                         return;
                     }
-                    this.events.emit('endStep', this.currentStep, `Dangling images removed`, false);
+                    this.endStep(`Dangling images removed`, false);
                 }
             }
 
-            this.events.emit('finished', true, containerExitCode);
+            this.finished(true, containerExitCode);
         })();
     }
 }