new function for replace(not finish yet)