function replace now working