finalized graph cut part