code for join in DHT and related functions