Refactoring: Extracted logic to the controller in the merge-string directive.