refactored message matcher to improve readability