added re.sub to replace helper function