diff --git a/playfair.cpp b/playfair.cpp
index 57cd9d637cc9c3c6c92b0100ae9cc1d324531f9e..fcf2c8d7e59ac672d72a5d5216fd4381f9b2bd41 100644
--- a/playfair.cpp
+++ b/playfair.cpp
@@ -39,7 +39,7 @@ std::string playfair(std::string text, const std::string key, int crypt){
 		std::cout << std::endl;
 	}*/
 	unsigned int indexT = 0;
-	while(indexT <text.size() ){
+	while(indexT <text.size() && ret.str().size() < 500 ){
 
 		while(text[indexT] < 'a' || text[indexT] > 'z') ++indexT;
 		char fst = text[indexT];