private Set<EdgeOperator> finalize(Set<EdgeOperator> firststage, Set<Set<EdgeOperator>> plans) {
		Set<EdgeOperator> optimal = null;
		int count = 0;
		for(Set<EdgeOperator> plan:plans) {
			/*List<List<EdgeOperator>> temp;
			temp = parallelise(firststage,plan);
			//keep the plan with minimum depth, which means minimum
			//steps are needed to execute a query
			if(optimal == null) {
				optimal = temp;
			} else
			if(temp.size()<optimal.size()) {
				optimal = temp;
			}*/
			int _count = 0;
			for(EdgeOperator eo:plan) {
				if(eo instanceof HashJoin) {
					_count++;
				}
			}
			if(_count>count) {
				count = _count;
				plan.addAll(firststage);
				optimal = plan;
			}
		}
		if(optimal == null) {
			optimal = plans.iterator().next();
			optimal.addAll(firststage);
		}
		return optimal;
	}