documentation for how algorithm works