fixed bug in treatment of horizontal edges