Implementation of string replacer