Implemented event handler for messages