match refactor