Finding bounderies with "closest to edges" method