improved message sending functionality