Improve match and logging