Integrate anne's and roman's algorithm

![](http://media3.giphy.com/media/pJScUQDqugV9e/200_s.gif)