build message logic imptoved