change broadcast to a template function