LPS-39536 Simplify logic by applying new replaceFirst method