fixed replication (backport pr #175 to master branch)

@dkulikovsky's version uses `next_node[0]` here. Does it matter?