moved edgecut computation to new function