message sending logic