Corrected re.sub and typos in variable names