Now the algorithm works (at least on the "Friends" example)