rewrite of the tablemerging routines (at metadata level)