private FreeTimeContainer getBestContainer(Task toPlan, ArrayList<FreeTimeContainer> possibilities) throws PlanningException {
		FreeTimeContainer best = null;
		Duration longestDuration = null;
		int index = -1;

		if (possibilities != null && possibilities.size() > 0) {
			index = getFirstPlannableContainerIndex(toPlan, possibilities);
			longestDuration = possibilities.get(index).getDurationLeft().minus(toPlan.getDuration());
			best = possibilities.get(index);
		} else
			throw new PlanningException(null, null, ApplicationSettings.getInstance().getLocalizedMessage("strat.noftc"));

		for (FreeTimeContainer container : possibilities) {
			Duration newDuration = container.getDurationLeft().minus(toPlan.getDuration());
			if (!newDuration.isNegative() && newDuration.compareTo(longestDuration) > 0) // found a better match
			{
				longestDuration = newDuration;
				best = container;
			}
		}
		return best;
	}