code refactory: consolidate UDP send function