refactor for mongodb replicaset