         FROM close_pair a, other_extreme b
     );
 
-
     INSERT INTO support(way) SELECT ST_MakeLine(rc2[1], rc2[3]);
     INSERT INTO support(way) SELECT ST_MakeLine(rc2[2], rc2[3]);
 
-    IF  rc2[2] = nesw[2] THEN
-        RAISE NOTICE 'north cut';
+    IF   (rc2[1] = nesw[4] AND rc2[2] = nesw[3]) OR (rc2[1] = nesw[3] AND rc2[2] = nesw[4]) THEN
+        RAISE NOTICE 'north-west cut';
     END IF;
-
-    -- INSERT INTO support(way)
-    -- SELECT ST_MakeLine(a.on_road, a.on_parcel)
-    -- FROM close_pair a
-    -- UNION
-    -- SELECT ST_MakeLine(a.on_road, b.on_parcel)
-    -- FROM close_pair a, other_extreme b;
-
 
     -- TODO: need to take the decision here on which
     -- direction to sweep in

    );
    INSERT INTO support(way) VALUES (bbox);

    -- in NESW we have all the extreme points on the boundary
    -- sorted by azimuth, so nesw[1] is north, nesw[2] is east
    -- nesw[3] is south, nesw[4] is west.

        ), center AS (
            -- get centroid of polygon defined by N,E,S,W extreme points
            SELECT
            ST_Centroid(ST_ExteriorRing(ST_Envelope(ST_Collect(p)))) AS c
            FROM unpacked
        ), sorted_cw AS (
            -- sort extreme points clock-wise
            SELECT
            a.p AS way
            FROM unpacked a, center b
            ORDER BY ST_Azimuth(b.c, a.p)
        )
        SELECT array_agg(way)
        FROM sorted_cw
