new algoritm.  much better.