Correction for replacing text in variable.
Addes if statments tom make it look abit more readeble.