corrected algorithms
solve problem