fix leader election bugs