merge all function