Leader election logic