cleaning up regexes and parameter passing