Updated the logic in the MessageReader sample