stupid question: how does this algorithm work?