synapse leader election
moved the leader election code to a method
Merge branch 'leader_election'