discrete algorithm running... slow however... grr