moved broadcast to c++ function