make the regex outside of the loop