Implementation of master node choose