LAC-9: rewrite merge operation