canny: while loop bug fixed