rewrote cooc algorithm again