corrected algorithms