fix logic of creating message