Fix message_ids assignment