split into transmit function.