algorithm fix 2