diff --git a/llama/main_automatic.go b/llama/main_automatic.go
index a4b336500b8e5edddcbfc20292c1047d4173c44f..906d6ef89c7314ebd1b7b1972980553c63b71546 100644
--- a/llama/main_automatic.go
+++ b/llama/main_automatic.go
@@ -43,42 +43,54 @@ func main() {
 		//	break
 		//}
 
-		var modifiedPrompt = userPrompt + extraction.GoPrompt
+		for {
 
-		fmt.Println("Prompt received. Generating response...")
+			if userPrompt == "exit" {
+				fmt.Println("Exiting the program.")
+				break
+			}
 
-		// Start a go routine to display a waiting indicator while the response is being generated
-		done := make(chan bool)
-		go displayindicator.DisplayLoadingIndicator(done)
+			var modifiedPrompt = userPrompt + extraction.GoPrompt
 
-		// Generate response using Ollama API, passing the context
-		response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext)
+			fmt.Println("Prompt received. Generating response...")
 
-		// Signal the waiting indicator to stop
-		done <- true
+			// Start a go routine to display a waiting indicator while the response is being generated
+			done := make(chan bool)
+			go displayindicator.DisplayLoadingIndicator(done)
 
-		if err != nil {
-			fmt.Println("Error generating response:", err)
-			continue
-		}
+			// Generate response using Ollama API, passing the context
+			response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext)
 
-		// Update the conversation context with the response
-		conversationContext = updatedContext
-		//fmt.Println(updatedContext)
+			// Signal the waiting indicator to stop
+			done <- true
 
-		generatedCode, _ := extraction.Extract(response) // Handle error with string
+			if err != nil {
+				fmt.Println("Error generating response:", err)
+				continue
+			}
 
-		fmt.Println("Ollama's response:", generatedCode)
+			// Update the conversation context with the response
+			conversationContext = updatedContext
 
-		output, err := compiler.CompileStringToGo(generatedCode)
+			generatedCode, err_extract := extraction.Extract(response) // Handle error with string
 
-		if err != nil {
-			fmt.Println("There were an error in the code that was compiled")
-			userPrompt = output + "\nFollowing are the errors, please fix the code. Write it again, and write only source code along with same test cases with no further explanation. The format should be ```rust <yourcode + testcases> ```"
-		} else {
-			fmt.Println("Compiled successfully. Here is the output: %v", output)
-			//userPrompt = "exit"
-		}
+			if err_extract != nil {
+				fmt.Printf("The LLM gave a improper string in response: %v", response)
+				userPrompt = "exit"
+				continue
+			}
+
+			fmt.Println("Ollama's response:", generatedCode)
 
+			output, err := compiler.CompileStringToGo(generatedCode)
+
+			if err != nil {
+				userPrompt = output + "\nFollowing are the errors, please fix the code. Write it again, and write only source code along with same test cases with no further explanation. The format should be ```rust <yourcode + testcases> ```"
+			} else {
+				fmt.Printf("Compiled successfully. Here is the output: %v", output)
+				userPrompt = "exit"
+			}
+
+		}
 	}
 }