clean up code to use regex object