updated for dynamic handling joing and leaving.