refactor the message extraction into a class
bugfix: typo in message_extractor