extracted write transmit buffer routine into it's own function