Improved placeholder replacement