updated addNode method inorder to handle replication