public int getShortestDistance(String word1, String word2, String text)
	{
	// initialized at the length of the full text, every distance found will be less
		int minDinstance = text.length();
		if(minDinstance == 0){
			// text is empty
			return -1;
		}
		String tempWord = "";
		String lastFoundWord = "";
		int counter = 0;

		StringTokenizer st = new StringTokenizer(text);
		while (st.hasMoreTokens()){
			counter++;
			// ignore special characters
			tempWord =  st.nextToken().replaceAll("[!?.:,]","");
			if(!tempWord.equalsIgnoreCase(word1)  && !tempWord.equalsIgnoreCase(word2))
			{
				//this words are between the 2 that we want
				continue;
			}
	
			// if we are here the current token is either word1 or word2
			
			
			if(!lastFoundWord.equalsIgnoreCase("") && !lastFoundWord.equalsIgnoreCase(tempWord) && counter < minDinstance)
			{
				// we found the 2 words and the distance is shorter than the current stored one, 
				// we updated it
				minDinstance = counter;
			}
	
			lastFoundWord = tempWord;
			counter = 0;
			

		}
		
		// if we found the 2 words we return the minimum distance otherwise we return -1
		return minDinstance != text.length() ? minDinstance : -1;

	}