working on fixing edge detection bug