added functionality to determine leader