BugFix Algorithm2