refactoring and preparing for proper udp communication