use a single scan using StringBuilder instead of the tripple String.replace