Made string replacement safer