implement cut and merge