improving the fast algorithm. Now is finally fast
TODO: still last bugs to get out and clean up flow