Updated messageId handling