Corrected a problem in algorithms