added logic of messages