refactor match