Fixed the stopping condition for the leader election algorithm