sorry, glaring oversight: that $replace() on the 4th last line should of course be $replacecs()