dropping main complexity down to N^3