Wrapped the regex thing in a function