refactor matchx