Fix algorithm!