fix substring replacement