Fixed traces replacing

The script was only replacing the first occurrence of traces.