update on merging function