Fixed the functionalty for replica sets