Refactor merge method.