Fix Edge Detection Algorithm