refactor out regex