improved the code about broadcasting