correctly initialize the replica and check for errors