diff --git a/Projet/CODE/apm/src/apm_gpu.cu b/Projet/CODE/apm/src/apm_gpu.cu
index 44cd14fc450a1989020f3b9277b8d2d07e401e93..ce4656c7ecdd420128eb326c3da41e6e5414c686 100644
--- a/Projet/CODE/apm/src/apm_gpu.cu
+++ b/Projet/CODE/apm/src/apm_gpu.cu
@@ -175,7 +175,7 @@ levenshtein_cu(char *find, char *buf, int len, int n_bytes
 {
 	int tId = blockIdx.x * blockDim.x + threadIdx.x;//global thread id
 
-	if (tId > n_bytes)
+	if (tId >= n_bytes - len)
 	{
 		return; //we are past the buffer length - do not process
 	}