New algorithm working