algorithm fix