Separate the message handling logic for easier extensibility