added logic to determine local network address dynamically