rewrite move and merge method