match refactored