public Rule cloneWithModeChange(final Mode toMode) throws RuleException {
		if ("".equals(toMode)) throw new RuleException("invalid mode [" + toMode + "] to convert");

		boolean isModified = false;

		Rule newRule = clone();
		List<Mode> modeUsedInBody = getModeUsedInBody();
		if (modeUsedInBody.size() == 0) {
		} else {
			for (Literal literal : newRule.body) {
				if (!toMode.equals(literal.getMode())) throw new RuleModeConversionException("inconsistent mode found in rule body");
			}
		}
		if (!toMode.equals(newRule.getMode())) {
			newRule.setMode(mode.clone());
			isModified = true;
		}
		for (Literal literal : newRule.head) {
			if (!"".equals(literal.getMode().toString()) && !toMode.equals(literal.getMode())) {
				literal.setMode(toMode.clone());
				isModified = true;
			}
		}

		if (!isModified) throw new RuleModeConversionException("no mode is modified");
		return newRule;
	}