implementing merge