replaceParams method optimization