Fix error caused by merge_cut
New merge_cut fuction is much complex. But works well.