Fixed the edge detection problem