fixed a minor bug with replace.