Implementation of the algorithm
Merge origin/master