heuristic basically works, need to add the random though to avoid loops.
works. todo: cleanup
cleanup. todo: documentation