add createReplaceFunction and test