Final version of the algorithm and the report