refactor for regex