Fixing the algorithm...