improve the replace