Fix algorithm