added ring buffer to TX function