fixed the \n problem in replace funct