@Override
    public Object execute(TransitionSystem ts, final Unifier un, final Term[] args) throws Exception {
        try {
	        final String s0;
	        if (args[0].isString())
	            s0 = ((StringTerm)args[0]).getString();
	        else 
	        	s0 = args[0].toString();
	        
	        final String s1;
	        if (args[1].isString())
	            s1 = ((StringTerm)args[1]).getString();
	        else
	        	s1 = args[1].toString();
	
	        if (args.length == 2) {
	        	// no backtracking utilisation
	            return s1.indexOf(s0) >= 0;
	        } else {
	        	
	        	// backtrack version: unifies in the third argument all possible positions of s0 in s1
	        	return new Iterator<Unifier>() {
	            	Unifier c = null; // the current response (which is an unifier)
	            	int     pos = 0;  // current position in s1
	            	
	            	public boolean hasNext() {
	            		if (c == null) // the first call of hasNext should find the first response 
	            			find();
	            		return c != null; 
	        		}
	
	            	public Unifier next() {
	            		if (c == null) find();
	            		Unifier b = c;
	            		find(); // find next response
	            		return b;
	            	}
	            	
	            	void find() {
	            		if (pos < s1.length()) {
		            		pos = s1.indexOf(s0,pos);
		            		if (pos >= 0) {
		                        c = (Unifier)un.clone();
		                    	c.unifiesNoUndo(args[2], new NumberTermImpl(pos));
		            			pos++;
		                    	return;
		                    }
		            		pos = s1.length(); // to stop searching
	            		}
	            		c = null; // no member is found,
	            	}
	
	            	public void remove() {}
	        	};
	            //return un.unifies(args[2], new NumberTermImpl(pos));
	        }
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new JasonException("The internal action 'substring' has not received two/three arguments.");
        } catch (Exception e) {
            throw new JasonException("Error in internal action 'substring': " + e, e);
        }
    }