refactor matcher code