update replication script to only execute when ismaster