public Map<Integer, StringBuilder> getCommandsForKeys(Collection<String> keys)
		throws MemcachedException {
		List activeList = hostListObj.getActiveList();
		String commandString = "get ";
		if (activeList == null || activeList.isEmpty()) {
			throw new MemcachedException("No active list available to service requests");
		}
		int size = activeList.size();

		//Keys seperated depending on the host assigned for it
		//Assuming there will be no changes in the activeList size.
		Map<Integer, StringBuilder> commandsMap = new HashMap<Integer, StringBuilder>(size);
		try {
			for (String key : keys) {
				if (key == null) {
					//skip
				} else {
					//code from org.quickserver.net.client.loaddistribution.impl.HashedLoadPattern
					int hash = key.hashCode();
					int mod = hash % size;
					if (mod < 0) {
						mod = mod * -1;
					}
					//--

					if (commandsMap.get(mod) != null) {
						commandsMap.get(mod).append(" ").append(key);
					} else {
						commandsMap.put(mod, new StringBuilder(commandString).append(key));
					}
				}
			}
		} catch (Exception e) {
			//log exception
			throw new MemcachedException("Invalid key/s found " + e);
		}
		return commandsMap;
	}