refactored udp client logic