private HashSet<String> getNextLayer(HashSet<String> currtLayer,
			HashSet<String> dict, String end, HashSet<String> visited, Map<String, Set<String>> path) {

		HashSet<String> nextLayer = new HashSet<String>();
		
		HashSet<String> visitedTemp = new HashSet<String>();
		
		for (String currtStr : currtLayer) {

			StringBuffer sb = new StringBuffer(currtStr);
			for (int i = 0; i < sb.length(); i++) {
				char currtChar = sb.charAt(i);

				for (char ch = 'a'; ch <= 'z'; ch++) {
					sb.setCharAt(i, ch);

					if (dict.contains(sb.toString())
							&& !visited.contains(sb.toString())) {
						nextLayer.add(sb.toString());
						visitedTemp.add(sb.toString());
						
						Set<String> pathSet = path.get(currtStr);
						if(pathSet == null) {
							pathSet = new HashSet<String>();
							pathSet.add(sb.toString());
							path.put(currtStr, pathSet);
						} else {
							pathSet.add(sb.toString());
						}
						
					}
				}
				sb.setCharAt(i, currtChar);
			}
		}
		
		visited.addAll(visitedTemp);
		return nextLayer;
	}