Fix script to replace correctly