fixed 'replace' script